RAS 19.1 script changes from the 18.1 script
Produced: 12/4/2022 4:31:07 PM
   
Mode:  Differences  
Left file: C:\gitstuff\Parallels-RAS-V19.x-Doc-Script-3.00\RAS_Inventory_V2.5.ps1  
Right file: C:\gitstuff\Parallels-RAS-V19.x-Doc-Script-3.00\RAS_Inventory_V3_0.ps1  
        Creates a complete inventory of a V18.1 or later Parallels Remote Application Server. <>         Creates a complete inventory of a V19.x or later Parallels Remote Application Server.
 
        Creates a complete inventory of a V18.1 or later Parallels Remote Application Server  <>         Creates a complete inventory of a V19.x or later Parallels Remote Application Server 
 
        June 1, 2021 at 6PM is 2021-06-01_1800. <>         June 1, 2023 at 6PM is 2023-06-01_1800.
 
        Output filename will be ReportName_2021-06-01_1800.<ext>. <>         Output filename will be ReportName_2023-06-01_1800.<ext>.
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -RASSite EMEASite <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -RASSite EMEASite
 
        PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -MSWord -CompanyName "Carl Webster  <>         PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -MSWord -CompanyName "Carl Webster 
 
        PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -PDF -CN "Carl Webster Consulting" -CP  <>         PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -PDF -CN "Carl Webster Consulting" -CP 
 
        PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -CompanyName "Sherlock Holmes  <>         PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -CompanyName "Sherlock Holmes 
 
        PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -CompanyName "Sherlock Holmes  <>         PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -CompanyName "Sherlock Holmes 
 
        PS C:\PSScript >.\RAS_Inventory_V2.5.ps1 -Dev -ScriptInfo -Log <>         PS C:\PSScript >.\RAS_Inventory_V3.0.ps1 -Dev -ScriptInfo -Log
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer mail.domain.tld -From  <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer mail.domain.tld -From 
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer mailrelay.domain.tld -From  <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer mailrelay.domain.tld -From 
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer  <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer 
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer smtp.office365.com -SmtpPort 587 <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer smtp.office365.com -SmtpPort 587
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer smtp.gmail.com -SmtpPort 587 <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer smtp.gmail.com -SmtpPort 587
 
        NAME: RAS_Inventory_V2.5.ps1 <>         NAME: RAS_Inventory_V3.0.ps1
        VERSION: 2.53           VERSION: 3.00
 
        LASTEDIT: February 13, 2022 <>         LASTEDIT: December 4, 2022
 
# <>  
#Version 2.53 13-Feb-2022    
#       When processing RD Session Hosts, the script had bad logic that assumed there was always only one RDS Group.    
#               This caused some Agent settings to show as System.Object[] instead of their Numeric or Boolean value    
#               For example:    
#                       Agent settings    
#                               Port                                                  : System.Object[]    
#                               Max Sessions                                          : System.Object[]    
#                               Support Windows Shell URL namespace objects           : System.Object[]    
#                               Allow 2xRemoteExec to send command to the client      : System.Object[]    
#                               Use RemoteApp if available                            : System.Object[]    
#                               Enable applications monitoring                        : System.Object[]    
#                               Allow file transfer command (HTML5 and Chrome clients): System.Object[]    
#                               Do not allow to change location                       : System.Object[]    
#                               Enable drive redirection cache                        : System.Object[]    
#               Oops, my bad. The fix only took one line of code and changing two variables.    
#               Now the results are correct.    
#                       Agent settings    
#                               Port                                                  : 3389    
#                               Max Sessions                                          : 25    
#                               Support Windows Shell URL namespace objects           : True    
#                               Allow 2xRemoteExec to send command to the client      : True    
#                               Use RemoteApp if available                            : False    
#                               Enable applications monitoring                        : True    
#                               Allow file transfer command (HTML5 and Chrome clients): True    
#                               Do not allow to change location                       : False    
#                               Enable drive redirection cache                        : True    
#               Thanks to Thomas Krampe for all his help and remote sessions to track this down    
#    
#Version 2.52 7-Feb-2022    
#       Added Function GetRASStatus to return the full status text for several RAS Status cmdlets    
#               Updated all AgentState outputs to use the value from GetRASStatus    
#       Added HALB output    
#               Virtual Servers    
#                       Properties    
#                       General    
#                       LB gateway payload    
#                       LB SSL payload    
#                       Devices    
#                       Advanced    
#       Changed the date format for the transcript and error log files from yyyy-MM-dd_HHmm format to the FileDateTime format    
#               The format is yyyyMMddTHHmmssffff (case-sensitive, using a 4-digit year, 2-digit month, 2-digit day,     
#               the letter T as a time separator, 2-digit hour, 2-digit minute, 2-digit second, and 4-digit millisecond).     
#               For example: 20221225T0840107271.    
#       Fixed call to Get-RASThemeFooterURL to always return an array (Thanks to Thomas Krampe for the debugging time)    
#       Fixed missing RDS Group Default settings (Thanks to Thomas Krampe)    
#       Fixed several logic errors where I assumed there were always RDS groups    
#       Fixed the German Table of Contents (Thanks to Rene Bigler)    
#               From     
#                       'de-'   { 'Automatische Tabelle 2'; Break }    
#               To    
#                       'de-'   { 'Automatisches Verzeichnis 2'; Break }    
#       For Policy setting Session/Connection/Primary connection/Login/Auto Login, change property name AutoStart to AutoLogin    
#       In Function AbortScript, add test for the winword process and terminate it if it is running    
#               Added stopping the transcript log if the log was enabled and started    
#       In Function OutputFarmSite, only get the first Publishing Agent server for the Farm/Site settings    
#       In Functions AbortScript and SaveandCloseDocumentandShutdownWord, add code from Guy Leech to test for the "Id" property before using it    
#       Replaced most script Exit calls with AbortScript to stop the transcript log if the log was enabled and started    
#       Updated the help text    
#       Updated the ReadMe file    
#       Updated to allow running the script for RAS versions greater than 18.1    
#    
#Version 2.51 11-Sep-2021    
#       Added array error checking for non-empty arrays before attempting to create the Word table for most Word tables    
#       Added Function OutputReportFooter    
#       Added Parameter ReportFooter    
#               Outputs a footer section at the end of the report.    
#               Report Footer    
#                       Report information:    
#                               Created with: <Script Name> - Release Date: <Script Release Date>    
#                               Script version: <Script Version>    
#                               Started on <Date Time in Local Format>    
#                               Elapsed time: nn days, nn hours, nn minutes, nn.nn seconds    
#                               Ran from domain <Domain Name> by user <Username>    
#                               Ran from the folder <Folder Name>    
#       Updated Functions SaveandCloseTextDocument and SaveandCloseHTMLDocument to add a "Report Complete" line    
#       Updated Functions ShowScriptOptions and ProcessScriptEnd to add $ReportFooter    
#       Updated the help text    
#       Updated the ReadMe file    
#    
#Version 2.50 12-Aug-2021    
#       Added a version test so the script only works with RAS 18.1    
#       Added documenting (my best attempt) an Azure provider connection    
#       Added Certificates    
#               Alternate Names    
#               General    
#                       Alternate Names    
#       Added Policies summary    
#       Added Policy Properties (took five days for this one section)    
#               Policy    
#               Policy/Criteria    
#               Session    
#               Session/Connection    
#               Session/Connection/Primary connection    
#               Session/Connection/Secondary connections    
#               Session/Connection/Reconnection    
#               Session/Connection/Computer name    
#               Session/Connection/Advanced settings    
#               Session/Connection/Web authentication    
#               Session/Connection/Multifactor authentication    
#               Session/Connection/Session prelaunch    
#               Session/Connection/Local proxy address    
#               Session/Display    
#               Session/Display/Settings    
#               Session/Display/Multi-monitor    
#               Session/Display/Published applications    
#               Session/Display/Desktop options    
#               Session/Display/Browser    
#               Session/Printing    
#               Session/Scanning    
#               Session/Audio    
#               Session/Keyboard    
#               Session/Local devices and resources    
#               Session/Local devices and resources/Clipboard    
#               Session/Local devices and resources/Disk drives    
#               Session/Local devices and resources/Devices    
#               Session/Local devices and resources/Video capture devices (not in PowerShell yet)    
#               Session/Local devices and resources/Ports    
#               Session/Local devices and resources/Smart cards    
#               Session/Local devices and resources/Windows touch input    
#               Session/Local devices and resources/File transfer    
#               Session/Experience    
#               Session/Experience/Performance    
#               Session/Experience/Compression    
#               Session/Network    
#               Session/Server authentication    
#               Session/Advanced settings    
#               Client options    
#               Client options/Connection    
#               Client options/Logging    
#               Client options/Update    
#               Client options/PC keyboard    
#               Client options/Single Sign-On    
#               Client options/Advanced    
#               Client options/Advanced/Global    
#               Client options/Advanced/Language    
#               Client options/Advanced/Printing    
#               Client options/Advanced/Windows client    
#               Client options/Advanced/RemoteFX USB redirection    
#               Control settings    
#               Control settings/Connections    
#               Control settings/Password    
#               Control settings/Import and export    
#               Redirection    
#       Added Reporting    
#               RAS reporting configuration    
#                       Session information    
#                       Server counters information    
#                       Custom reports    
#               RAS Performance Monitor configuration    
#       Added Themes    
#               General    
#               Messages    
#               HTML5 client/Branding    
#               HTML5 client/Language bar    
#               HTML5 client/Messages    
#               HTML5 client/Gateway    
#               HTML5 client/Legal policies    
#               Windows client/Branding    
#               Windows client/Messages    
#               Windows client/Custom menu    
#       Added to Connection/Multi-factor authentication:    
#               Enable MFA for all users except    
#               Disable MFA for all users except    
#               User or group list    
#               Updated all items and text to match the console (a lot of work)    
#               Added for Azure RADIUS, Duo RADIUS, FortiAuthenticator RADIUS, TekRADIUS, and RADIUS    
#                       Connection    
#                       Attributes    
#                       Automation    
#               Added DeepNet Provider    
#                       Connection    
#                       Application    
#                       Authentication    
#               Added SafeNet Provider    
#                       Connection    
#                       Authentication    
#               Added Google Authenticator    
#                       General    
#       Added to Gateway and Gateway Default Settings:    
#               HTML5/Allow cross-origin resource sharing    
#                       Domains for cross-origin resource sharing    
#                       Browser cache time in months    
#               HTML5/Clipboard redirection    
#               HTML5/File Transfer Direction    
#               HTML5/Use ciphers according to server preference    
#               Wyse/Do not warn if server certificate is not verified    
#       Added to Provider/Agent settings Drag and drop    
#       Added to Published Items their Status    
#               Disabled    
#               Enabled    
#               In maintenance    
#       Added to RD Session Host, RD Session Host Groups, Provider and Default Site Settings:    
#               Agent settings/File Transfer Direction    
#               Agent settings/File Transfer Location    
#               Agent settings/File Transfer Do not allow to change location    
#       Change the wording in Connection/Authentication and Multi-factor authentication to match the console    
#       Fixed a lot of HTML and text formatting issues    
#       In Certificates/General, moved Expiration date to before Common name    
#       In Published Resources, only show Associated File Extensions if the EnableFileExtensions property is True    
#               If you add file extensions and later disable file extensions, the extensions previously entered are still there    
#       Renamed in Gateway/SSL/TLS/HSTS settings "Max-age" to "Browse cache time in months"    
#       Renamed in RDS Host/Agent, RDS Group/Agent, and Provider/Agent settings:    
#               "Support Shell URL namespace objects" to "Support Windows Shell URL namespace objects"    
#       Removed the Restrictions label from Gateways/HTML5 as it is no longer in the console    
#       Updated Function GetVDIType with Hypervisor data for ESXi 7.0 and vCenter 7.0    
#       Updated the Help text    
#       Updated the ReadMe file    
#    
#Version 2.10 25-Apr-2021   #Work on 3.0 started on 15-Nov-2022
#       Fixed wrong variables used to determine User Profile technology    
#       For RD Session Hosts properties:    
#               Renamed the Properties tab to General    
#               Renamed Agent Settings to Agent settings    
#               Renamed User Profile to User profile    
#               Renamed Desktop Access to Desktop access    
#               Renamed RDP Printer to RDP printer    
#       For RD Session Hosts Groups properties:    
#               Renamed Agent Settings to Agent settings    
#               Renamed Desktop Access to Desktop access    
#               Renamed RDP Printer to RDP printer    
#       For RD Session Hosts Schedule properties:    
#               Renamed the Properties tab to General    
#       For VDI Providers properties:    
#               Renamed Agent Settings to Agent settings    
#               Renamed RDP Printer to RDP printer    
#       For Gateways properties:    
#               Renamed the Properties tab to General    
#       For Certificates properties:    
#               Renamed the Properties tab to General    
#       For Administration, Settings:    
#               Rename Customer Experience Program to Customer experience program    
#               Rename HTTP Proxy settings to HTTP proxy settings    
#       For License:    
#               Rename License Details to License details    
#       For VDI, the following changes were made:    
#               Providers tab, added Direct address    
#               Providers properties, renamed the Properties tab to General    
#               Providers properties, Agent settings:    
#                       Removed "Publishing Session Timeout"    
#                       Added "Enable drive redirection cache"    
#               Pools tab:    
#                       Pools:    
#                               Added Last modification by    
#                               Added Modified on    
#                               Added Created by    
#                               Added Created on    
#               Templates tab:    
#                       For template properties, removed Status as I was getting the wrong status property    
#                       Template properties, renamed the Properties tab to General    
#                       Advanced tab, renamed Native Pool to Resource pool    
#       Updated the ReadMe file    
#    
#Version 2.00 20-Apr-2021    
#       Added 59 RDS Agent States    
#       Added a message to the error message for the missing RAS module    
#               Added a link to the V2 ReadMe file    
#       Added a parameter, RASSite, allowing the report to contain data for the specified Site    
#       Added additional Notification handlers types    
#       Added FSLogix to Farm/Site/Settings/Features    
#       Added Function GetFarmSites    
#       Added the missing License section for published RDSH applications to Text and HTML output    
#       Added to Universal Printing/Printer drivers, "Settings are replicated to all Sites"    
#       Added UPD and FSLogix to the User Profile tab for both RD Session Hosts and RD Session Hosts/Groups    
#       Added VDI Pool Member type of "ALLGUESTSONPROVIDER"    
#       Added WVD Apps and Desktops to Publishing    
#       Changed $DesktopSize to use the new values of the DesktopSize property    
#               Removed the property UseAvailableArea as it no longer exists    
#       Changed all RAS cmdlet names to use the new naming scheme Get-RAS*    
#       Changed all Write-Verbose statements from Get-Date to Get-Date -Format G as requested by Guy Leech    
#       Changed Get-RASVDIHost to the new Get-RASProvider    
#       Changed Get-RASVDIHostStatus to the new Get-RASProviderStatus    
#       Changed PoSH module from PSAdmin to RASAdmin    
#       Changed some Write-Warnings to Write-Host as they are not warnings    
#               Reformat most of the Write-Host statements to make the console output look better    
#       Changed the font size of Word/PDF tables from 11 to 10 to prevent most word wrapping to multiple lines    
#       Changed the RDS User Profile Technology to one line instead of two    
#       Changed the variable $MasterPublishingAgent to $PrimaryPublishingAgent    
#               Changed the matching column headings from Master Publishing Agent to Primary Publishing Agent    
#       Changed TWAIN and WIA state from "Unable to retrieve ___ Scanning information" to $False if unable to retrieve data or retrieved no data    
#       Fixed several alignment issues in the text output    
#       Fixed several formatting issues with the HTML and Word/PDF output    
#       Fixed several invalid $Null comparisons    
#       For RD Session Hosts, Agent settings, add the option Enable drive redirection cache    
#       For replicating settings, standardized on the wording "Settings are replicated to all Sites" followed by True or False    
#       In the Administration section, add the following:    
#               Accounts, Receive system notifications    
#               Settings, Miscellaneous, Reset idle RAS Console session after    
#       In the Connection section, add the following:    
#               Allowed devices, headings for Secure Access and Device Access    
#               Allowed devices, Allow only clients with the latest security patches    
#               Allowed devices, Device Access, Mode text label    
#       In the Filters section, reformatted the output to make it more readable (at least to me)    
#       In the Load Balancing section added CPU Optimization    
#       Moved Notification from Administration to Site Settings    
#       Removed all Turbo.net content    
#       Removed Function ProcessSites    
#       Removed MaxGuests from Provider/Agent Settings    
#       Removed property EnableCPULB from Load Balancing section    
#       Removed UPD settings from RD Session Hosts properties and Groups properties    
#       Reorder Parameters in an order recommended by Guy Leech    
#       Reworked how the script processed a Farm with multiple Sites    
#               For most of the Get-RAS* cmdlets, where needed, added the -Site parameter    
#       Updated Function SetWordCellFormat to the latest version    
#       Updated the Allowed authentication types to the new text in the console and handled multiple selections    
#       Updated the help text    
#       Updated the ReadMe file    
#       When retrieving data for Gateways, set variables to values specifying if the Gateway data could not be retrieved or found no Gateway data    
#       When using the output from Get-RASVDITemplate, change VDIHostId to ProviderId    
#       With the addition of the "Last modification by", "Modified on", "Created by", and "Created on"     
#               properties to the PowerShell cmdlets, add those four properties to the relevant report sections    
 
  -+ $SaveEAPreference         = $ErrorActionPreference
    $ErrorActionPreference    = 'SilentlyContinue'
    $Error.Clear()
     
 
$script:MyVersion         = '2.53' <> $script:MyVersion         = '3.00.015'
$Script:ScriptName        = "RAS_Inventory_V2.5.ps1"   $Script:ScriptName        = "RAS_Inventory_V3.0.ps1"
$tmpdate                  = [datetime] "02/13/2022"   $tmpdate                  = [datetime] "12/04/2022"
 
        [int]$wdColorBlack            = 0 <>         #[int]$wdColorBlack            = 0
        [int]$wdColorGray05           = 15987699            #[int]$wdColorGray05           = 15987699 
 
        [int]$wdColorRed              = 255 <>         #[int]$wdColorRed              = 255
 
        [int]$wdColorYellow           = 65535 <>         #[int]$wdColorYellow           = 65535
 
        [int]$wdAlignParagraphLeft = 0 <>         #[int]$wdAlignParagraphLeft = 0
        [int]$wdAlignParagraphCenter = 1           #[int]$wdAlignParagraphCenter = 1
        [int]$wdAlignParagraphRight = 2           #[int]$wdAlignParagraphRight = 2
 
        [int]$wdCellAlignVerticalTop = 0 <>         #[int]$wdCellAlignVerticalTop = 0
        [int]$wdCellAlignVerticalCenter = 1           #[int]$wdCellAlignVerticalCenter = 1
        [int]$wdCellAlignVerticalBottom = 2           #[int]$wdCellAlignVerticalBottom = 2
 
        [int]$wdAutoFitWindow = 2 <>         #[int]$wdAutoFitWindow = 2
 
        [int]$wdAdjustNone = 0 <>         #[int]$wdAdjustNone = 0
 
        [int]$wdAdjustFirstColumn = 2 <>         #[int]$wdAdjustFirstColumn = 2
        [int]$wdAdjustSameWidth = 3           #[int]$wdAdjustSameWidth = 3
 
        [int]$Indent1TabStops = 1 * $PointsPerTabStop <>         #[int]$Indent1TabStops = 1 * $PointsPerTabStop
        [int]$Indent2TabStops = 2 * $PointsPerTabStop           #[int]$Indent2TabStops = 2 * $PointsPerTabStop
        [int]$Indent3TabStops = 3 * $PointsPerTabStop           #[int]$Indent3TabStops = 3 * $PointsPerTabStop
        [int]$Indent4TabStops = 4 * $PointsPerTabStop           #[int]$Indent4TabStops = 4 * $PointsPerTabStop
 
  -+         [int]$wdStyleHeading5 = -6
 
        [int]$wdTableLightListAccent3 = -206 <>         #[int]$wdTableLightListAccent3 = -206
 
  -+         $Script:myHash.Word_Heading5        = $wdStyleheading5
 
  -+                 5 {$Script:Selection.Style = $Script:MyHash.Word_Heading5; Break}
 
        Write-Verbose "$(Get-Date -Format G): RAS Version          : $($Script:RASVersion)" +-  
 
  -+                 $Script:RASFullVersion = $Results
 
                If([version]$Script:RASVersion -ge [version]"18.1") <>                 If([version]$Script:RASVersion -ge [version]"19.1")
 
        This script is designed for RAS 18.1 and should not be run on $Results. <>         This script is designed for RAS 19.1 and should not be run on $Results.
 
        If you are running RAS 18.0, please use:  <>         If you are running RAS 18.x, please use: 
 
  -+                 $Script:RASFullVersion = "Unable to determine"
 
        This script is designed for RAS 18.1 and your RAS version could not be determined. <>         This script is designed for RAS 19.1 and your RAS version could not be determined.
 
        If you are running RAS 18.0, please use:  <>         If you are running RAS 18.x, please use: 
 
                Out-File -FilePath $SIFile -Append -InputObject "RAS Version          : $Script:RASVersion" 4>$Null +-  
 
                 +-  
                OutputFarm    
 
                $Results = Get-RASPA -SiteId $Site.Id -EA 0 4> $Null | Select -First 1 #changed in 2.52 to only get the first PA <>                 $Results = Get-RASBroker -SiteId $Site.Id -EA 0 4> $Null | Select-Object -First 1 #changed in 2.52 to only get the first PA
 
                $ScriptInformation.Add(@{Data = "Primary Publishing Agent"; Value = $PrimaryPublishingAgent; }) > $Null <>                 $ScriptInformation.Add(@{Data = "Primary Connection Broker"; Value = $PrimaryPublishingAgent; }) > $Null
 
                Line 1 "Site`t`t`t: " $Site.Name <>                 Line 1 "Site`t`t`t : " $Site.Name
                Line 1 "Primary Publishing Agent: " $PrimaryPublishingAgent                   Line 1 "Primary Connection Broker: " $PrimaryPublishingAgent
                Line 1 "Type`t`t`t: " $Type                   Line 1 "Type`t`t`t : " $Type
                Line 1 "State`t`t`t: " $State                   Line 1 "State`t`t`t : " $State
                Line 1 "Description`t`t: " $Description                   Line 1 "Description`t`t : " $Description
                Line 1 "ID`t`t`t: " $ID                   Line 1 "ID`t`t`t : " $ID
                Line 1 "Last modification by`t: " $Site.AdminLastMod                   Line 1 "Last modification by`t : " $Site.AdminLastMod
                Line 1 "Modified on`t`t: " $Site.TimeLastMod.ToString()                   Line 1 "Modified on`t`t : " $Site.TimeLastMod.ToString()
                Line 1 "Created by`t`t: " $Site.AdminCreate                   Line 1 "Created by`t`t : " $Site.AdminCreate
                Line 1 "Created on`t`t: " $Site.TimeCreate.ToString()                   Line 1 "Created on`t`t : " $Site.TimeCreate.ToString()
 
                $rowdata += @(,("Primary Publishing Agent",($Script:htmlsb),$PrimaryPublishingAgent,$htmlwhite)) <>                 $rowdata += @(,("Primary Connection Broker",($Script:htmlsb),$PrimaryPublishingAgent,$htmlwhite))
 
  -+                 "HyperVWin2022Std"                                      {$VDIType = "HyperV on Windows Server 2022 Standard Edition"; Break}
                    "HyperVWin2022Dtc"                                      {$VDIType = "HyperV on Windows Server 2022 Datacenter Edition"; Break}
 
  -+                 "HyperVFailoverClusterWin2022"          {$VDIType = "HyperV Failover Cluster on Windows Server 2022"; Break}
 
  -+                 15                                                                      {$VDIType = "Vmware VCenter Server 7.0"; Break}
 
  <>                 "Nutanix5_5"                                            {$VDIType = "Nutanix 5.5"; Break}
                    "Nutanix5_10"                                           {$VDIType = "Nutanix 5.10"; Break}
                    "Nutanix5_15"                                           {$VDIType = "Nutanix 5.15"; Break}
                    "Nutanix5_20"                                           {$VDIType = "Nutanix 5.20"; Break}
                    "Nutanix6_5"                                            {$VDIType = "Nutanix 6.5"; Break}
                "RemotePCUnknown"                                       {$VDIType = "Remote PC Unknown"; Break}                   "RemotePCStaticUnknown"                         {$VDIType = "Remote PC static unknown"; Break}
 
  -+                 "RemotePCDynamicUnknown"                        {$VDIType = "Remote PC dynamic unknown"; Break}
 
  -+                 "Scale"                                                         {$VDIType = "Scale unknown"; Break}
 
  <>                 "Scale8_6_5"                                            {$VDIType = "Scale 8.6.5"; Break}
                    "Scale8_8"                                                      {$VDIType = "Scale 8.8"; Break}
                    "Scale8_9"                                                      {$VDIType = "Scale 8.9"; Break}
                    "Scale9_1"                                                      {$VDIType = "Scale 9.1"; Break}
                "Azure"                                                         {$VDIType = "Azure"; Break}                                                        "Azure"                                                         {$VDIType = "Azure"; Break}
                    21                                                                      {$VDIType = "Azure"; Break}
                    "AzureUnknown"                                          {$VDIType = "Azure"; Break}                                     
                    "AVD"                                                           {$VDIType = "AVD"; Break}                                       
                    "AWSEC2"                                                        {$VDIType = "AWSEC2"; Break}                                    
 
  -+                 #""                                             {$FullRASStatus = ""; Break}
                    "AddingMembers"                                 {$FullRASStatus = "Guest being added to the group"; Break}
 
  -+                 "DeleteInProgress"                              {$FullRASStatus = "A delete is currently in progress"; Break}
 
  -+                 "FailedPerfCounters"                    {$FullRASStatus = "Performance counters failed to initialize"; Break}
 
  -+                 "JoiningToGroup"                                {$FullRASStatus = "A host is current being joined to a group or hostpool"; Break}
 
  -+                 "NoAvailableGateways"                   {$FullRASStatus = "There are no RAS Secure Gateways that the Tenant Broker can use to process connections"; Break}
 
  -+                 "PendingRecreation"                             {$FullRASStatus = "Machine will be recreated on the last user logoff"; Break}
 
  -+                 "RemovingMembers"                               {$FullRASStatus = "Guest being removed from the group"; Break}
                    "ScalingIn"                                             {$FullRASStatus = "Deprecated: use RemovingMembers instead"; Break}
                    "ScalingOut"                                    {$FullRASStatus = "Deprecated: use AddingMembers instead"; Break}
 
                                Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)` <>                                 Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)`
 
                                        WriteWordLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         WriteWordLine 0 0 "Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)"
 
                                        Line 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         Line 0 "Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)"
 
                                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)"
 
                                No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)` <>                                 No RDS Status retrieved for RDS Host $($RDSHost.Server)`
 
                                        WriteWordLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         WriteWordLine 0 0 "No RDS Status retrieved for RDS Host $($RDSHost.Server)"
 
                                        Line 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         Line 0 "No RDS Status retrieved for RDS Host $($RDSHost.Server)"
 
                                        WriteHTMLLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         WriteHTMLLine 0 0 "No RDS Status retrieved for RDS Host $($RDSHost.Server)"
 
                                        $ScriptInformation.Add(@{Data = "Address"; Value = $RDSHost.Server; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Name"; Value = $RDSHost.Server; }) > $Null
 
                                        $ScriptInformation.Add(@{Data = "Preferred PA"; Value = $RDSStatus.PreferredPA; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $RDSStatus.PreferredBroker; }) > $Null
 
                                        $Table.Columns.Item(2).Width = 250; <>                                         $Table.Columns.Item(2).Width = 300;
 
                                        Line 2 "Address`t`t: " $RDSHost.Server <>                                         Line 2 "Name`t`t`t`t: " $RDSHost.Server
                                        Line 2 "Status`t`t: " $RDSStatusAgentState                                           Line 2 "Status`t`t`t`t: " $RDSStatusAgentState
                                        Line 2 "CPU`t`t: " "$($RDSStatus.CPULoad)%"                                           Line 2 "CPU`t`t`t`t: " "$($RDSStatus.CPULoad)%"
                                        Line 2 "RAM`t`t: " "$($RDSStatus.MemLoad)%"                                           Line 2 "RAM`t`t`t`t: " "$($RDSStatus.MemLoad)%"
                                        Line 2 "Disk read time`t: " "$($RDSStatus.DiskRead)%"                                           Line 2 "Disk read time`t`t`t: " "$($RDSStatus.DiskRead)%"
                                        Line 2 "Disk write time`t: " "$($RDSStatus.DiskWrite)%"                                           Line 2 "Disk write time`t`t`t: " "$($RDSStatus.DiskWrite)%"
                                        Line 2 "Sessions`t: " $Sessions                                           Line 2 "Sessions`t`t`t: " $Sessions
                                        Line 2 "Preferred PA`t: " $RDSStatus.PreferredPA                                           Line 2 "Preferred Connection Broker`t: " $RDSStatus.PreferredBroker
                                        Line 2 "Operating system: " $RDSStatus.ServerOS                                           Line 2 "Operating system`t`t: " $RDSStatus.ServerOS
                                        Line 2 "Agent version`t: " $RDSStatus.AgentVer                                           Line 2 "Agent version`t`t`t: " $RDSStatus.AgentVer
 
                                        $columnHeaders = @("Address",($Script:htmlsb),$RDSHost.Server,$htmlwhite) <>                                         $columnHeaders = @("Name",($Script:htmlsb),$RDSHost.Server,$htmlwhite)
 
                                        $rowdata += @(,("Preferred PA",($Script:htmlsb),$RDSStatus.PreferredPA,$htmlwhite)) <>                                         $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$RDSStatus.PreferredBroker,$htmlwhite))
 
                                        $columnWidths = @("200","275") <>                                         $columnWidths = @("200","350")
 
        $VDIHosts = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null <>         $Providers = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null
 
                Unable to retrieve VDI for Site $($Site.Name)` <>                 Unable to retrieve Providers for Site $($Site.Name)`
 
                        WriteWordLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"
 
                        Line 0 "Unable to retrieve VDI for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve Providers for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"
 
        ElseIf($? -and $Null -eq $VDIHosts) <>         ElseIf($? -and $Null -eq $Providers)
 
                No VDI retrieved for Site $($Site.Name).` <>                 No Providers retrieved for Site $($Site.Name).`
 
                        WriteWordLine 0 0 "No VDI retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "No Providers retrieved for Site $($Site.Name)"
 
                        Line 0 "No VDI retrieved for Site $($Site.Name)" <>                         Line 0 "No Providers retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No VDI retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "No Providers retrieved for Site $($Site.Name)"
 
                        WriteWordLine 2 0 "VDI Providers" <>                         WriteWordLine 2 0 "Providers"
 
                        Line 1 "VDI Providers" <>                         Line 1 "Providers"
 
                        WriteHTMLLine 2 0 "VDI Providers" <>                         WriteHTMLLine 2 0 "Providers"
 
                Write-Verbose "$(Get-Date -Format G): `t`tOutput VDI Providers" <>                 Write-Verbose "$(Get-Date -Format G): `t`tOutput Providers"
                ForEach($VDIHost in $VDIHosts)                   ForEach($Provider in $Providers)
 
                        $VDIHostStatus = Get-RASProviderStatus -Id $VDIHost.Id -EA 0 4>$Null <>                         $Providerstatus = Get-RASProviderStatus -Id $Provider.Id -EA 0 4>$Null
 
                                Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)` <>                                 Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)`
 
                                        WriteWordLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)" <>                                         WriteWordLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)"
 
                                        Line 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)" <>                                         Line 0 "Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)"
 
                                        WriteHTMLLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)"
 
                        ElseIf($? -and $Null -eq $VDIHostStatus) <>                         ElseIf($? -and $Null -eq $Providerstatus)
 
                                No VDI Host Status retrieved for VDI Host $($VDIHost.Id)` <>                                 No VDI Host Status retrieved for VDI Host $($Provider.Id)`
 
                                        WriteWordLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)" <>                                         WriteWordLine 0 0 "No VDI Host Status retrieved for VDI Host $($Provider.Id)"
 
                                        Line 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)" <>                                         Line 0 "No VDI Host Status retrieved for VDI Host $($Provider.Id)"
 
                                        WriteHTMLLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)" <>                                         WriteHTMLLine 0 0 "No VDI Host Status retrieved for VDI Host $($Provider.Id)"
 
                                $FullProviderStatus = GetRASStatus $VDIHostStatus.AgentState <>                                 $FullProviderStatus = GetRASStatus $Providerstatus.AgentState
 
                                        $ScriptInformation.Add(@{Data = "Address"; Value = $VDIHost.Server; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Server; }) > $Null
 
                                        $ScriptInformation.Add(@{Data = "CPU"; Value = "$($VDIHostStatus.CPULoad)%"; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "CPU"; Value = "$($Providerstatus.CPULoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "RAM"; Value = "$($VDIHostStatus.MemLoad)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "RAM"; Value = "$($Providerstatus.MemLoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($VDIHostStatus.DiskRead)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($Providerstatus.DiskRead)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($VDIHostStatus.DiskWrite)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($Providerstatus.DiskWrite)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Preferred PA"; Value = $VDIHostStatus.PreferredPA; }) > $Null                                           $ScriptInformation.Add(@{Data = "Preferred COnnection Broker"; Value = $Providerstatus.PreferredBroker; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Operating system"; Value = $VDIHostStatus.ServerOS; }) > $Null                                           $ScriptInformation.Add(@{Data = "Operating system"; Value = $Providerstatus.ServerOS; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Agent version"; Value = $VDIHostStatus.AgentVer; }) > $Null                                           $ScriptInformation.Add(@{Data = "Agent version"; Value = $Providerstatus.AgentVer; }) > $Null
 
                                        $Table.Columns.Item(2).Width = 250; <>                                         $Table.Columns.Item(2).Width = 300;
 
                                        Line 2 "Address`t`t: " $VDIHost.Server <>                                         Line 2 "Name`t`t`t`t: " $Provider.Server
                                        Line 2 "Status`t`t: " $FullProviderStatus                                           Line 2 "Status`t`t`t`t: " $FullProviderStatus
                                        Line 2 "CPU`t`t: " "$($VDIHostStatus.CPULoad)%"                                           Line 2 "CPU`t`t`t`t: " "$($Providerstatus.CPULoad)%"
                                        Line 2 "RAM`t`t: " "$($VDIHostStatus.MemLoad)%"                                           Line 2 "RAM`t`t`t`t: " "$($Providerstatus.MemLoad)%"
                                        Line 2 "Disk read time`t: " "$($VDIHostStatus.DiskRead)%"                                           Line 2 "Disk read time`t`t`t: " "$($Providerstatus.DiskRead)%"
                                        Line 2 "Disk write time`t: " "$($VDIHostStatus.DiskWrite)%"                                           Line 2 "Disk write time`t`t`t: " "$($Providerstatus.DiskWrite)%"
                                        Line 2 "Preferred PA`t: " $VDIHostStatus.PreferredPA                                           Line 2 "Preferred Connection Broker`t: " $Providerstatus.PreferredBroker
                                        Line 2 "Operating system: " $VDIHostStatus.ServerOS                                           Line 2 "Operating system`t`t: " $Providerstatus.ServerOS
                                        Line 2 "Agent version`t: " $VDIHostStatus.AgentVer                                           Line 2 "Agent version`t`t`t: " $Providerstatus.AgentVer
 
                                        $columnHeaders = @("Address",($Script:htmlsb),$VDIHost.Server,$htmlwhite) <>                                         $columnHeaders = @("Name",($Script:htmlsb),$Provider.Server,$htmlwhite)
 
                                        $rowdata += @(,("CPU",($Script:htmlsb),"$($VDIHostStatus.CPULoad)%",$htmlwhite)) <>                                         $rowdata += @(,("CPU",($Script:htmlsb),"$($Providerstatus.CPULoad)%",$htmlwhite))
                                        $rowdata += @(,("RAM",($Script:htmlsb),"$($VDIHostStatus.MemLoad)%",$htmlwhite))                                           $rowdata += @(,("RAM",($Script:htmlsb),"$($Providerstatus.MemLoad)%",$htmlwhite))
                                        $rowdata += @(,("Disk read time",($Script:htmlsb),"$($VDIHostStatus.DiskRead)%",$htmlwhite))                                           $rowdata += @(,("Disk read time",($Script:htmlsb),"$($Providerstatus.DiskRead)%",$htmlwhite))
                                        $rowdata += @(,("Disk write time",($Script:htmlsb),"$($VDIHostStatus.DiskWrite)%",$htmlwhite))                                           $rowdata += @(,("Disk write time",($Script:htmlsb),"$($Providerstatus.DiskWrite)%",$htmlwhite))
                                        $rowdata += @(,("Preferred PA",($Script:htmlsb),$VDIHostStatus.PreferredPA,$htmlwhite))                                           $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$Providerstatus.PreferredBroker,$htmlwhite))
                                        $rowdata += @(,("Operating system",($Script:htmlsb),$VDIHostStatus.ServerOS,$htmlwhite))                                           $rowdata += @(,("Operating system",($Script:htmlsb),$Providerstatus.ServerOS,$htmlwhite))
                                        $rowdata += @(,("Agent version",($Script:htmlsb),$VDIHostStatus.AgentVer,$htmlwhite))                                           $rowdata += @(,("Agent version",($Script:htmlsb),$Providerstatus.AgentVer,$htmlwhite))
 
                                        $columnWidths = @("200","275") <>                                         $columnWidths = @("200","350")
 
        $GWs = Get-RASGW -Siteid $Site.Id -EA 0 4> $Null <>         $SecureGateways = Get-RASGateway -Siteid $Site.Id -EA 0 4> $Null
 
                Unable to retrieve Gateways for Site $($Site.Name)` <>                 Unable to retrieve Secure Gateways for Site $($Site.Name)`
 
                        WriteWordLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"
 
                        Line 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"
 
        ElseIf($? -and $Null -eq $GWs) <>         ElseIf($? -and $Null -eq $SecureGateways)
 
                No Gateways retrieved for Site $($Site.Name).` <>                 No Secure Gateways retrieved for Site $($Site.Name).`
 
                        WriteWordLine 0 0 "No Gateways retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "No Secure Gateways retrieved for Site $($Site.Name)"
 
                        Line 0 "No Gateways retrieved for Site $($Site.Name)" <>                         Line 0 "No Secure Gateways retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No Gateways retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "No Secure Gateways retrieved for Site $($Site.Name)"
 
                        WriteWordLine 2 0 "Gateways" <>                         WriteWordLine 2 0 "Secure Gateways"
 
                        Line 1 "Gateways" <>                         Line 1 "Secure Gateways"
 
                        WriteHTMLLine 2 0 "Gateways" <>                         WriteHTMLLine 2 0 "Secure Gateways"
 
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Site Gateways" <>                 Write-Verbose "$(Get-Date -Format G): `t`tOutput Site Secure Gateways"
                ForEach($GW in $GWs)                   ForEach($SecureGateway in $SecureGateways)
 
                        $GWStatus = Get-RASGWStatus -Id $GW.Id -EA 0 4>$Null <>                         $SecureGatewayStatus = Get-RASGatewayStatus -Id $SecureGateway.Id -EA 0 4>$Null
 
                                Unable to retrieve Gateway Status for Gateway $($GW.Id)` <>                                 Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)`
 
                                        WriteWordLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)" <>                                         WriteWordLine 0 0 "Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)"
 
                                        Line 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)" <>                                         Line 0 "Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)"
 
                                        WriteHTMLLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)"
 
                        ElseIf($? -and $Null -eq $GWStatus) <>                         ElseIf($? -and $Null -eq $SecureGatewayStatus)
 
                                No Gateway Status retrieved for Gateway $($GW.Id)` <>                                 No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)`
 
                                        WriteWordLine 0 0 "No Gateway Status retrieved for Gateway $($GW.Id)" <>                                         WriteWordLine 0 0 "No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)"
 
                                        Line 0 "No Gateway Status retrieved for Gateway $($GW.Id)" <>                                         Line 0 "No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)"
 
                                        WriteHTMLLine 0 0 "No Gateway Status retrieved for Gateway $($GW.Id)" <>                                         WriteHTMLLine 0 0 "No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)"
 
                                $Sessions = ($GWStatus.ActiveRDPSessions + $GWStatus.ActiveRDPSSLSessions) <>                                 $Sessions = ($SecureGatewayStatus.ActiveRDPSessions + $SecureGatewayStatus.ActiveRDPSSLSessions)
                                $GWStatusAgentState = GetRASStatus $GWStatus.AgentState                                   $SecureGatewayStatusAgentState = GetRASStatus $SecureGatewayStatus.AgentState
 
                                        $ScriptInformation.Add(@{Data = "Address"; Value = $GW.Server; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Name"; Value = $SecureGateway.Server; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $GWStatusAgentState; }) > $Null                                           $ScriptInformation.Add(@{Data = "Status"; Value = $SecureGatewayStatusAgentState; }) > $Null
                                        $ScriptInformation.Add(@{Data = "CPU"; Value = "$($GWStatus.CPULoad)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "CPU"; Value = "$($SecureGatewayStatus.CPULoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "RAM"; Value = "$($GWStatus.MemLoad)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "RAM"; Value = "$($SecureGatewayStatus.MemLoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($GWStatus.DiskRead)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($SecureGatewayStatus.DiskRead)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($GWStatus.DiskWrite)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($SecureGatewayStatus.DiskWrite)%"; }) > $Null
 
                                        $ScriptInformation.Add(@{Data = "Preferred PA"; Value = $GWStatus.PreferredPA; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $SecureGatewayStatus.PreferredBroker; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Operating system"; Value = $GWStatus.ServerOS; }) > $Null                                           $ScriptInformation.Add(@{Data = "Operating system"; Value = $SecureGatewayStatus.ServerOS; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Agent version"; Value = $GWStatus.AgentVer; }) > $Null                                           $ScriptInformation.Add(@{Data = "Agent version"; Value = $SecureGatewayStatus.AgentVer; }) > $Null
 
                                        $Table.Columns.Item(2).Width = 250; <>                                         $Table.Columns.Item(2).Width = 300;
 
                                        Line 2 "Address`t`t: " $GW.Server <>                                         Line 2 "Name`t`t`t`t: " $SecureGateway.Server
                                        Line 2 "Status`t`t: " $GWStatusAgentState                                           Line 2 "Status`t`t`t`t: " $SecureGatewayStatusAgentState
                                        Line 2 "CPU`t`t: " "$($GWStatus.CPULoad)%"                                           Line 2 "CPU`t`t`t`t: " "$($SecureGatewayStatus.CPULoad)%"
                                        Line 2 "RAM`t`t: " "$($GWStatus.MemLoad)%"                                           Line 2 "RAM`t`t`t`t: " "$($SecureGatewayStatus.MemLoad)%"
                                        Line 2 "Disk read time`t: " "$($GWStatus.DiskRead)%"                                           Line 2 "Disk read time`t`t`t: " "$($SecureGatewayStatus.DiskRead)%"
                                        Line 2 "Disk write time`t: " "$($GWStatus.DiskWrite)%"                                           Line 2 "Disk write time`t`t`t: " "$($SecureGatewayStatus.DiskWrite)%"
                                        Line 2 "Sessions`t: " $Sessions.ToString()                                           Line 2 "Sessions`t`t`t: " $Sessions.ToString()
                                        Line 2 "Preferred PA`t: " $GWStatus.PreferredPA                                           Line 2 "Preferred Connection Broker`t: " $SecureGatewayStatus.PreferredBroker
                                        Line 2 "Operating system: " $GWStatus.ServerOS                                           Line 2 "Operating system`t`t: " $SecureGatewayStatus.ServerOS
                                        Line 2 "Agent version`t: " $GWStatus.AgentVer                                           Line 2 "Agent version`t`t`t: " $SecureGatewayStatus.AgentVer
 
                                        $columnHeaders = @("Address",($Script:htmlsb),$GW.Server,$htmlwhite) <>                                         $columnHeaders = @("Name",($Script:htmlsb),$SecureGateway.Server,$htmlwhite)
                                        $rowdata += @(,("Status",($Script:htmlsb),$GWStatusAgentState.ToString(),$htmlwhite))                                           $rowdata += @(,("Status",($Script:htmlsb),$SecureGatewayStatusAgentState.ToString(),$htmlwhite))
                                        $rowdata += @(,("CPU",($Script:htmlsb),"$($GWStatus.CPULoad)%",$htmlwhite))                                           $rowdata += @(,("CPU",($Script:htmlsb),"$($SecureGatewayStatus.CPULoad)%",$htmlwhite))
                                        $rowdata += @(,("RAM",($Script:htmlsb),"$($GWStatus.MemLoad)%",$htmlwhite))                                           $rowdata += @(,("RAM",($Script:htmlsb),"$($SecureGatewayStatus.MemLoad)%",$htmlwhite))
                                        $rowdata += @(,("Disk read time",($Script:htmlsb),"$($GWStatus.DiskRead)%",$htmlwhite))                                           $rowdata += @(,("Disk read time",($Script:htmlsb),"$($SecureGatewayStatus.DiskRead)%",$htmlwhite))
                                        $rowdata += @(,("Disk write time",($Script:htmlsb),"$($GWStatus.DiskWrite)%",$htmlwhite))                                           $rowdata += @(,("Disk write time",($Script:htmlsb),"$($SecureGatewayStatus.DiskWrite)%",$htmlwhite))
 
                                        $rowdata += @(,("Preferred PA",($Script:htmlsb),$GWStatus.PreferredPA,$htmlwhite)) <>                                         $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$SecureGatewayStatus.PreferredBroker,$htmlwhite))
                                        $rowdata += @(,("Operating system",($Script:htmlsb),$GWStatus.ServerOS,$htmlwhite))                                           $rowdata += @(,("Operating system",($Script:htmlsb),$SecureGatewayStatus.ServerOS,$htmlwhite))
                                        $rowdata += @(,("Agent version",($Script:htmlsb),$GWStatus.AgentVer,$htmlwhite))                                           $rowdata += @(,("Agent version",($Script:htmlsb),$SecureGatewayStatus.AgentVer,$htmlwhite))
 
                                        $columnWidths = @("200","275") <>                                         $columnWidths = @("200","350")
 
        $PAs = Get-RASPA -Siteid $Site.Id -EA 0 4> $Null <>         $ConnectionBrokers = Get-RASBroker -Siteid $Site.Id -EA 0 4> $Null
 
                Unable to retrieve Publishing Agents for Site $($Site.Name)` <>                 Unable to retrieve Connection Brokers for Site $($Site.Name)`
 
                        WriteWordLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
 
                        Line 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
 
        ElseIf($? -and $Null -eq $PAs) <>         ElseIf($? -and $Null -eq $ConnectionBrokers)
 
                No Publishing Agents retrieved for Site $($Site.Name).` <>                 No Connection Brokers retrieved for Site $($Site.Name).`
 
                        WriteWordLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)"
 
                        Line 0 "No Publishing Agents retrieved for Site $($Site.Name)" <>                         Line 0 "No Connection Brokers retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)"
 
                        WriteWordLine 2 0 "Publishing Agents" <>                         WriteWordLine 2 0 "Connection Brokers"
 
                        Line 1 "Publishing Agents" <>                         Line 1 "Connection Brokers"
 
                        WriteHTMLLine 2 0 "Publishing Agents" <>                         WriteHTMLLine 2 0 "Connection Brokers"
 
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Publishing Agents" <>                 Write-Verbose "$(Get-Date -Format G): `t`tOutput Connection Brokers"
                ForEach($PA in $PAs)                   ForEach($ConnectionBroker in $ConnectionBrokers)
 
                        $PAStatus = Get-RASPAStatus -Id $PA.Id -EA 0 4>$Null <>                         $ConnectionBrokerStatus = Get-RASBrokerStatus -Id $ConnectionBroker.Id -EA 0 4>$Null
 
                                Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)` <>                                 Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)`
 
                                        WriteWordLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         WriteWordLine 0 0 "Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)"
 
                                        Line 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         Line 0 "Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)"
 
                                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)"
 
                        ElseIf($? -and $Null -eq $PAStatus) <>                         ElseIf($? -and $Null -eq $ConnectionBrokerStatus)
 
                                No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)` <>                                 No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)`
 
                                        WriteWordLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         WriteWordLine 0 0 "No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)"
 
                                        Line 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         Line 0 "No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)"
 
                                        WriteHTMLLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         WriteHTMLLine 0 0 "No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)"
 
  <>                                 If($ConnectionBroker.Priority -eq 0)
                                    {
                                            $ConnectionBrokerPriority = "Primary"
                                    }
                                    Else
                                    {
                                            $ConnectionBrokerPriority = "Secondary"
                                    }
                                    
                                $PAStatusAgentState = GetRASStatus $PAStatus.AgentState                                   $ConnectionBrokerStatusAgentState = GetRASStatus $ConnectionBrokerStatus.AgentState
 
                                        $ScriptInformation.Add(@{Data = "Address"; Value = $PA.Server; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Name"; Value = $ConnectionBroker.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Priority"; Value = $ConnectionBrokerPriority; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $PAStatusAgentState; }) > $Null                                           $ScriptInformation.Add(@{Data = "Status"; Value = $ConnectionBrokerStatusAgentState; }) > $Null
                                        $ScriptInformation.Add(@{Data = "CPU"; Value = "$($PAStatus.CPULoad)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "CPU"; Value = "$($ConnectionBrokerStatus.CPULoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "RAM"; Value = "$($PAStatus.MemLoad)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "RAM"; Value = "$($ConnectionBrokerStatus.MemLoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($PAStatus.DiskRead)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($ConnectionBrokerStatus.DiskRead)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($PAStatus.DiskWrite)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($ConnectionBrokerStatus.DiskWrite)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Operating system"; Value = $PAStatus.ServerOS; }) > $Null                                           $ScriptInformation.Add(@{Data = "Operating system"; Value = $ConnectionBrokerStatus.ServerOS; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Agent version"; Value = $PAStatus.AgentVer; }) > $Null                                           $ScriptInformation.Add(@{Data = "Agent version"; Value = $ConnectionBrokerStatus.AgentVer; }) > $Null
 
                                        $Table.Columns.Item(2).Width = 250; <>                                         $Table.Columns.Item(2).Width = 300;
 
                                        Line 2 "Address`t`t: " $PA.Server <>                                         Line 2 "Name`t`t: " $ConnectionBroker.Server
                                            Line 2 "Priority`t: " $ConnectionBrokerPriority
                                        Line 2 "Status`t`t: " $PAStatusAgentState                                           Line 2 "Status`t`t: " $ConnectionBrokerStatusAgentState
                                        Line 2 "CPU`t`t: " "$($PAStatus.CPULoad)%"                                           Line 2 "CPU`t`t: " "$($ConnectionBrokerStatus.CPULoad)%"
                                        Line 2 "RAM`t`t: " "$($PAStatus.MemLoad)%"                                           Line 2 "RAM`t`t: " "$($ConnectionBrokerStatus.MemLoad)%"
                                        Line 2 "Disk read time`t: " "$($PAStatus.DiskRead)%"                                           Line 2 "Disk read time`t: " "$($ConnectionBrokerStatus.DiskRead)%"
                                        Line 2 "Disk write time`t: " "$($PAStatus.DiskWrite)%"                                           Line 2 "Disk write time`t: " "$($ConnectionBrokerStatus.DiskWrite)%"
                                        Line 2 "Operating system: " $PAStatus.ServerOS                                           Line 2 "Operating system: " $ConnectionBrokerStatus.ServerOS
                                        Line 2 "Agent version`t: " $PAStatus.AgentVer                                           Line 2 "Agent version`t: " $ConnectionBrokerStatus.AgentVer
 
                                        $columnHeaders = @("Address",($Script:htmlsb),$PA.Server,$htmlwhite) <>                                         $columnHeaders = @("Name",($Script:htmlsb),$ConnectionBroker.Server,$htmlwhite)
                                            $rowdata += @(,("Priority",($Script:htmlsb),$ConnectionBrokerPriority,$htmlwhite))
                                        $rowdata += @(,("Status",($Script:htmlsb),$PAStatusAgentState.ToString(),$htmlwhite))                                           $rowdata += @(,("Status",($Script:htmlsb),$ConnectionBrokerStatusAgentState.ToString(),$htmlwhite))
                                        $rowdata += @(,("CPU",($Script:htmlsb),"$($PAStatus.CPULoad)%",$htmlwhite))                                           $rowdata += @(,("CPU",($Script:htmlsb),"$($ConnectionBrokerStatus.CPULoad)%",$htmlwhite))
                                        $rowdata += @(,("RAM",($Script:htmlsb),"$($PAStatus.MemLoad)%",$htmlwhite))                                           $rowdata += @(,("RAM",($Script:htmlsb),"$($ConnectionBrokerStatus.MemLoad)%",$htmlwhite))
                                        $rowdata += @(,("Disk read time",($Script:htmlsb),"$($PAStatus.DiskRead)%",$htmlwhite))                                           $rowdata += @(,("Disk read time",($Script:htmlsb),"$($ConnectionBrokerStatus.DiskRead)%",$htmlwhite))
                                        $rowdata += @(,("Disk write time",($Script:htmlsb),"$($PAStatus.DiskWrite)%",$htmlwhite))                                           $rowdata += @(,("Disk write time",($Script:htmlsb),"$($ConnectionBrokerStatus.DiskWrite)%",$htmlwhite))
                                        $rowdata += @(,("Operating system",($Script:htmlsb),$PAStatus.ServerOS,$htmlwhite))                                           $rowdata += @(,("Operating system",($Script:htmlsb),$ConnectionBrokerStatus.ServerOS,$htmlwhite))
                                        $rowdata += @(,("Agent version",($Script:htmlsb),$PAStatus.AgentVer,$htmlwhite))                                           $rowdata += @(,("Agent version",($Script:htmlsb),$ConnectionBrokerStatus.AgentVer,$htmlwhite))
 
                                        $columnWidths = @("200","275") <>                                         $columnWidths = @("200","350")
 
                                $Status      = "N/A" +-  
 
                                Line 4 "Enable server in site`t`t`t`t`t: " $RDSHost.Enabled.ToString() <>                                 Line 4 "Enable server in site`t: " $RDSHost.Enabled.ToString()
                                Line 4 "Server`t`t`t`t`t`t`t: " $RDSHost.Server                                   Line 4 "Server`t`t`t: " $RDSHost.Server
                                Line 4 "Description`t`t`t`t`t`t: " $RDSHost.Description                                   Line 4 "Description`t`t: " $RDSHost.Description
                                Line 4 "Direct Address`t`t`t`t`t`t: " $RDSHost.DirectAddress                                   Line 4 "Direct Address`t`t: " $RDSHost.DirectAddress
 
                                                                "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                                                 "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                                     Break}
                                                                "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                                                   "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                                     Break}
                                                                "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                                                   "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                                     $ReplaceRegisteredApplication = "True";
                                                                                                                                     Break}
                                                                Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($GroupDefaults.AllowURLAndMailRedirection)"; Break}                                                                   Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($GroupDefaults.AllowURLAndMailRedirection)";
                                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                                     Break}
 
                                                                "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                                                 "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                                                    $RDSAllowDragAndDrop = "True";
                                                                    Break}
                                                                "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                                                   "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                                                    $RDSAllowDragAndDrop = "False";
                                                                    Break}
                                                                "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                                                   "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                                                    $RDSAllowDragAndDrop = "True";
                                                                    Break}
                                                                "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                                                   "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                                                    $RDSAllowDragAndDrop = "True";
                                                                    Break}
                                                                Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($GroupDefaults.DragAndDropMode)"; Break}                                                                   Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($GroupDefaults.DragAndDropMode)";
                                                                    $RDSAllowDragAndDrop = "False";
                                                                    Break}
 
                                                        If($GroupDefaults.PreferredPAId -eq 0) <>                                                         If($GroupDefaults.PreferredBrokerId -eq 0)
 
                                                                $RDSPreferredPublishingAgent = (Get-RASPA -Id $GroupDefaults.PreferredPAId -EA 0 4>$Null).Server <>                                                                 $RDSPreferredPublishingAgent = (Get-RASBroker -Id $GroupDefaults.PreferredBrokerId -EA 0 4>$Null).Server
 
                                                                        "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                                                         "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                                                             Break}
                                                                        "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                                                           "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                                                             Break}
                                                                        "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                                                           "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                                             $ReplaceRegisteredApplication = "True";
                                                                                                                                             Break}
                                                                        Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)"; Break}                                                                           Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)";
                                                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                                                             Break}
 
                                                                        "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                                                         "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                                                            $RDSAllowDragAndDrop = "True";
                                                                            Break}
                                                                        "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                                                           "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                                                            $RDSAllowDragAndDrop = "False";
                                                                            Break}
                                                                        "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                                                           "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                                                            $RDSAllowDragAndDrop = "True";
                                                                            Break}
                                                                        "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                                                           "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                                                            $RDSAllowDragAndDrop = "True";
                                                                            Break}
                                                                        Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)"; Break}                                                                           Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)";
                                                                            $RDSAllowDragAndDrop = "False";
                                                                            Break}
 
                                                                If($RDSDefaults.PreferredPAId -eq 0) <>                                                                 If($RDSDefaults.PreferredBrokerId -eq 0)
 
                                                                        $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSDefaults.PreferredPAId -EA 0 4>$Null).Server <>                                                                         $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSDefaults.PreferredBrokerId -EA 0 4>$Null).Server
 
  -+                                                                 $ReplaceRegisteredApplication          = "False"
 
  -+                                                                 $RDSAllowDragAndDrop                   = "Enabled"
 
                                                "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                                 "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
                                                "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                                   "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
                                                "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                                   "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                     $ReplaceRegisteredApplication = "True";
                                                                                                                     Break}
                                                Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)"; Break}                                                   Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
 
                                                "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                                 "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                                   "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                                    $RDSAllowDragAndDrop = "False";
                                                    Break}
                                                "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                                   "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                                   "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)"; Break}                                                   Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)";
                                                    $RDSAllowDragAndDrop = "False";
                                                    Break}
 
                                        If($RDSHost.PreferredPAId -eq 0) <>                                         If($RDSHost.PreferredBrokerId -eq 0)
 
                                                $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSHost.PreferredPAId -EA 0 4>$Null).Server <>                                                 $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSHost.PreferredBrokerId -EA 0 4>$Null).Server
 
                                        "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                         "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                        "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                           "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                        "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                           "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                             $ReplaceRegisteredApplication = "True";
                                                                                                             Break}
                                        Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)"; Break}                                           Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
 
                                        "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                         "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                           "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                            $RDSAllowDragAndDrop = "False";
                                            Break}
                                        "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                           "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                           "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)"; Break}                                           Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)";
                                            $RDSAllowDragAndDrop = "False";
                                            Break}
 
                                If($RDSHost.PreferredPAId -eq 0) <>                                 If($RDSHost.PreferredBrokerId -eq 0)
 
                                        $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSHost.PreferredPAId -EA 0 4>$Null).Server <>                                         $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSHost.PreferredBrokerId -EA 0 4>$Null).Server
 
  <>                                 $ScriptInformation.Add(@{Data = "Application session lingering"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Disconnect active session after"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Logoff disconnected session after"; Value = $RDSPublishingSessionResetTime; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Other settings"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "Port"; Value = $RDSPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Port"; Value = $RDSPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Max Sessions"; Value = $RDSMaxSessions; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Max Sessions"; Value = $RDSMaxSessions; }) > $Null
                                $ScriptInformation.Add(@{Data = "Publishing Session Disconnect Timeout"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Publishing Session Reset Timeout"; Value = $RDSPublishingSessionResetTime; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Preferred Connection Broker"; Value = $RDSPreferredPublishingAgent; }) > $Null
 
  <>                                 $ScriptInformation.Add(@{Data = "     Replace registered application"; Value = $ReplaceRegisteredApplication; }) > $Null
                                $ScriptInformation.Add(@{Data = "Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null
                                $ScriptInformation.Add(@{Data = "Drag and drop"; Value = $RDSDragAndDrop; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable Drag and drop"; Value = $RDSAllowDragandDrop; }) > $Null
                                $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $RDSPreferredPublishingAgent; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSDragAndDrop; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Allow file transfer command (HTML5 and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Allow file transfer command (Web (HTML5) and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null
                                $ScriptInformation.Add(@{Data = "Configure File Transfer"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Configure File Transfer"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSFileTransferMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Direction"; Value = $RDSFileTransferMode; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Location"; Value = $RDSFileTransferLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Location"; Value = $RDSFileTransferLocation; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null
 
                                Line 4 "Inherit default settings`t`t`t`t: " $RDSHost.InheritDefaultAgentSettings.ToString() <>                                 Line 4 "Inherit default settings`t`t`t`t`t: " $RDSHost.InheritDefaultAgentSettings.ToString()
                                    Line 4 "Application session lingering"
                                    Line 5 "Disconnect active session after`t`t`t`t: " $RDSPublishingSessionDisconnectTimeout
                                    Line 5 "Logoff disconnected session after`t`t`t: " $RDSPublishingSessionResetTime
                                    Line 4 "Other settings"
                                Line 4 "Port`t`t`t`t`t`t`t: " $RDSPort                                   Line 5 "Port`t`t`t`t`t`t`t: " $RDSPort
                                Line 4 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions                                   Line 5 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions
                                Line 4 "Publishing Session Disconnect Timeout`t`t`t: " $RDSPublishingSessionDisconnectTimeout    
                                Line 4 "Publishing Session Reset Timeout`t`t`t: " $RDSPublishingSessionResetTime                                   Line 5 "Preferred Connection Broker`t`t`t`t: " $RDSPreferredPublishingAgent
                                Line 4 "Allow Client URL/Mail Redirection`t`t`t: " $RDSAllowClientURLMailRedirection                                   Line 4 "Allow Client URL/Mail Redirection`t`t`t`t: " $RDSAllowClientURLMailRedirection
                                    Line 5 "Replace registered application`t`t`t`t: " $ReplaceRegisteredApplication
                                Line 4 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject                                   Line 5 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject
                                Line 4 "Drag and drop`t`t`t`t`t`t: " $RDSDragAndDrop                                   Line 4 "Enable Drag and drop`t`t`t`t`t`t: " $RDSAllowDragandDrop
                                Line 4 "Preferred Publishing Agent`t`t`t`t: " $RDSPreferredPublishingAgent                                   Line 5 "Direction`t`t`t`t`t`t: " $RDSDragAndDrop
                                Line 4 "Allow 2xRemoteExec to send command to the client`t: " $RDSAllowRemoteExec                                   Line 4 "Allow 2xRemoteExec to send command to the client`t`t: " $RDSAllowRemoteExec
                                Line 4 "Use RemoteApp if available`t`t`t`t: " $RDSUseRemoteApps                                   Line 4 "Use RemoteApp if available`t`t`t`t`t: " $RDSUseRemoteApps
                                Line 4 "Enable applications monitoring`t`t`t`t: " $RDSEnableAppMonitoring                                   Line 4 "Enable applications monitoring`t`t`t`t`t: " $RDSEnableAppMonitoring
                                Line 4 "Allow file transfer command (HTML5 and Chrome clients)`t: " $RDSAllowFileTransfer                                   Line 4 "Allow file transfer command (Web (HTML5) and Chrome clients)`t: " $RDSAllowFileTransfer
                                Line 4 "Configure File Transfer"                                   Line 5 "Configure File Transfer"
                                Line 5 "Direction`t`t`t: " $RDSFileTransferMode                                   Line 6 "Direction`t`t`t: " $RDSFileTransferMode
                                Line 5 "Location`t`t`t: " $RDSFileTransferLocation                                   Line 6 "Location`t`t`t: " $RDSFileTransferLocation
                                Line 5 "Do not allow to change location`t: " $RDSFileTransferChangeLocation                                   Line 6 "Do not allow to change location : " $RDSFileTransferChangeLocation
                                Line 4 "Enable drive redirection cache`t`t`t`t: " $RDSEnableDriveRedirectionCache                                   Line 4 "Enable drive redirection cache`t`t`t`t`t: " $RDSEnableDriveRedirectionCache
 
  <>                                 $rowdata += @(,("Application session lingering",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("     Disconnect active session after",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))
                                    $rowdata += @(,("     Logoff disconnected session after",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))
                                    $rowdata += @(,("Other settings",($Script:htmlsb),$RDSPort,$htmlwhite))
                                $rowdata += @(,("Port",($Script:htmlsb),$RDSPort,$htmlwhite))                                   $rowdata += @(,("     Port",($Script:htmlsb),$RDSPort,$htmlwhite))
                                $rowdata += @(,("Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))                                   $rowdata += @(,("     Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))
                                $rowdata += @(,("Publishing Session Disconnect Timeout",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))    
                                $rowdata += @(,("Publishing Session Reset Timeout",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))                                   $rowdata += @(,("     Preferred Connection Broker",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))
 
  <>                                 $rowdata += @(,("     Replace registered application",($Script:htmlsb),$ReplaceRegisteredApplication,$htmlwhite))
                                $rowdata += @(,("Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))                                   $rowdata += @(,("     Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))
                                $rowdata += @(,("Drag and drop",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))                                   $rowdata += @(,("Enable Drag and drop",($Script:htmlsb),$RDSAllowDragandDrop,$htmlwhite))
                                $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))                                   $rowdata += @(,("     Direction",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))
 
                                $rowdata += @(,("Allow file transfer command (HTML5 and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite)) <>                                 $rowdata += @(,("Allow file transfer command (Web (HTML5) and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite))
                                $rowdata += @(,("Configure File Transfer",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Configure File Transfer",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("     Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))                                   $rowdata += @(,("          Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))
                                $rowdata += @(,("     Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))                                   $rowdata += @(,("          Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))
                                $rowdata += @(,("     Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))                                   $rowdata += @(,("          Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))
 
                        #Desktop Access <>                         #Optimization
 
                                WriteWordLine 4 0 "Desktop access" <>                                 WriteWordLine 4 0 "Optimization"
 
                                Line 3 "Desktop access" <>                                 Line 3 "Optimization"
 
                         <>  
                            <#
                            Get-RASImageOptimization -Id 1 -ObjType RDS
     
                            EnableOptimization            : True
                            OptimizationType              : Automatic
                            WindowsDefenderATP            : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsDefenderATP
                            WindowsComponents             : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsComponents
                            WindowsDefenderATPEnabled     : True
                            WindowsComponentsEnabled      : True
                            WindowsServicesEnabled        : True
                            WindowsScheduledTasksEnabled  : True
                            WindowsAdvancedOptionsEnabled : True
                            NetworkPerformanceEnabled     : True
                            RegistryEnabled               : True
                            VisualEffectsEnabled          : True
                            DiskCleanupEnabled            : True
                            CustomScriptEnabled           : False
                            WindowsServices               : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsServices
                            WindowsAdvancedOptions        : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsAdvancedOptions
                            NetworkPerformance            : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.NetworkPerformance
                            CustomScript                  : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.CustomScript
                            DiskCleanup                   : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.DiskCleanup
                            VisualEffects                 : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.VisualEffects
                            WindowsScheduledTasks         : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsScheduledTasks
                            Registry                      : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.Registries
                            #>
     
                        If($RDSHost.InheritDefaultDesktopAccessSettings)                           If($RDSHost.InheritDefaultOptimizationSettings)
 
                                $Results = Get-RASRDSGroup -SiteId $Site.Id -EA 0 4>$Null <>                                 $RDSGroup = Get-RASRDSGroup -SiteId $Site.Id -EA 0 4>$Null
 
                                If($? -and $Null -ne $Results) <>                                 If($? -and $Null -ne $RDSGroup)
 
                                        If($Results.RDSIds -Contains $RDSHost.Id ) <>                                         If($RDSGroup.RDSIds -Contains $RDSHost.Id )
 
                                                If($Results.InheritDefaultDesktopAccessSettings -eq $False) <>                                                 If($RDSGroup.InheritDefaultOptimizationSettings -eq $False)
 
                                                        $GroupDefaults = $Results.RDSDefSettings <>                                                         $OPTEnableOptimization            = $RDSGroup.Optimization.EnableOptimization.ToString()
                                                            $OPTOptimizationType              = $RDSGroup.Optimization.OptimizationType.ToString()
                                                        $RDSRestrictDesktopAccess = $GroupDefaults.RestrictDesktopAccess.ToString()                                                           $OPTWindowsDefenderATPEnabled     = $RDSGroup.Optimization.WindowsDefenderATPEnabled.ToString()    
                                                        $RDSRestrictedUsers       = @()                                                           $OPTWindowsComponentsEnabled      = $RDSGroup.Optimization.WindowsComponentsEnabled.ToString()
                                                                                                                  $OPTWindowsServicesEnabled        = $RDSGroup.Optimization.WindowsServicesEnabled.ToString()
                                                        ForEach($User in $GroupDefaults.RestrictedUsers)                                                           $OPTWinodwsScheduledTasksEnabled  = $RDSGroup.Optimization.WindowsScheduledTasksEnabled.ToString()
                                                        {                                                           $OPTWindowsAdvancedOptionsEnabled = $RDSGroup.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                                            $OPTNetworkPerformanceEnabled     = $RDSGroup.Optimization.NetworkPerformanceEnabled.ToString()
                                                                $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)                                                           $OPTRegistryEnabled               = $RDSGroup.Optimization.RegistryEnabled.ToString()
                                                                $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])                                                           $OPTVisualEffectsEnabled          = $RDSGroup.Optimization.VisualEffectsEnabled.ToString()   
                                                                                                                          $OPTDiskCleanupEnabled            = $RDSGroup.Optimization.DiskCleanupEnabled.ToString()
                                                                $RDSRestrictedUsers += $objUser.Value                                                           $OPTCustomScriptEnabled           = $RDSGroup.Optimization.CustomScriptEnabled.ToString()
                                                        }    
 
                                                                $RDSRestrictDesktopAccess = $RDSDefaults.RestrictDesktopAccess.ToString() <>                                                                 $OPTEnableOptimization            = $RDSDefaults.Optimization.EnableOptimization.ToString()
                                                                $RDSRestrictedUsers       = @()                                                                   $OPTOptimizationType              = $RDSDefaults.Optimization.OptimizationType.ToString()
                                                                                                                                  $OPTWindowsDefenderATPEnabled     = $RDSDefaults.Optimization.WindowsDefenderATPEnabled.ToString()    
                                                                ForEach($User in $RDSDefaults.RestrictedUsers)                                                                   $OPTWindowsComponentsEnabled      = $RDSDefaults.Optimization.WindowsComponentsEnabled.ToString()
                                                                {                                                                   $OPTWindowsServicesEnabled        = $RDSDefaults.Optimization.WindowsServicesEnabled.ToString()
                                                                    $OPTWinodwsScheduledTasksEnabled  = $RDSDefaults.Optimization.WindowsScheduledTasksEnabled.ToString()
                                                                    $OPTWindowsAdvancedOptionsEnabled = $RDSDefaults.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                                                    $OPTNetworkPerformanceEnabled     = $RDSDefaults.Optimization.NetworkPerformanceEnabled.ToString()
                                                                        $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)                                                                   $OPTRegistryEnabled               = $RDSDefaults.Optimization.RegistryEnabled.ToString()
                                                                    $OPTVisualEffectsEnabled          = $RDSDefaults.Optimization.VisualEffectsEnabled.ToString()   
                                                                    $OPTDiskCleanupEnabled            = $RDSDefaults.Optimization.DiskCleanupEnabled.ToString()
                                                                        $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])                                                                   $OPTCustomScriptEnabled           = $RDSDefaults.Optimization.CustomScriptEnabled.ToString()
                                                                            
                                                                        $RDSRestrictedUsers += $objUser.Value    
                                                                }    
 
  <>                                                                 $OPTEnableOptimization            = "False"
                                                                    $OPTOptimizationType              = ""
                                                                    $OPTWindowsDefenderATPEnabled     = "False"
                                                                    $OPTWindowsComponentsEnabled      = "False"
                                                                    $OPTWindowsServicesEnabled        = "False"
                                                                    $OPTWinodwsScheduledTasksEnabled  = "False"
                                                                    $OPTWindowsAdvancedOptionsEnabled = "False"
                                                                    $OPTNetworkPerformanceEnabled     = "False"
                                                                    $OPTRegistryEnabled               = "False"
                                                                    $OPTVisualEffectsEnabled          = "False"
                                                                    $OPTDiskCleanupEnabled            = "False"
                                                                $RDSRestrictDesktopAccess = "False"                                                                   $OPTCustomScriptEnabled           = "False"
                                                                $RDSRestrictedUsers       = @()    
 
                                        $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString() +-  
                                        $RDSRestrictedUsers       = @()    
 
                                        ForEach($User in $RDSHost.RestrictedUsers) <>                                         $OPTEnableOptimization            = $RDSHost.Optimization.EnableOptimization.ToString()
                                        {                                           $OPTOptimizationType              = $RDSHost.Optimization.OptimizationType.ToString()
                                            $OPTWindowsDefenderATPEnabled     = $RDSHost.Optimization.WindowsDefenderATPEnabled.ToString()    
                                            $OPTWindowsComponentsEnabled      = $RDSHost.Optimization.WindowsComponentsEnabled.ToString()
                                            $OPTWindowsServicesEnabled        = $RDSHost.Optimization.WindowsServicesEnabled.ToString()
                                            $OPTWinodwsScheduledTasksEnabled  = $RDSHost.Optimization.WindowsScheduledTasksEnabled.ToString()
                                            $OPTWindowsAdvancedOptionsEnabled = $RDSHost.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                            $OPTNetworkPerformanceEnabled     = $RDSHost.Optimization.NetworkPerformanceEnabled.ToString()
                                                $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)                                           $OPTRegistryEnabled               = $RDSHost.Optimization.RegistryEnabled.ToString()
                                            $OPTVisualEffectsEnabled          = $RDSHost.Optimization.VisualEffectsEnabled.ToString()   
                                            $OPTDiskCleanupEnabled            = $RDSHost.Optimization.DiskCleanupEnabled.ToString()
                                                $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])                                           $OPTCustomScriptEnabled           = $RDSHost.Optimization.CustomScriptEnabled.ToString()
                                                    
                                                $RDSRestrictedUsers += $objUser.Value    
                                        }    
 
                                $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString() +-  
                                $RDSRestrictedUsers       = @()    
 
                                ForEach($User in $RDSHost.RestrictedUsers) <>                                 $OPTEnableOptimization            = $RDSHost.Optimization.EnableOptimization.ToString()
                                {                                   $OPTOptimizationType              = $RDSHost.Optimization.OptimizationType.ToString()
                                    $OPTWindowsDefenderATPEnabled     = $RDSHost.Optimization.WindowsDefenderATPEnabled.ToString()    
                                    $OPTWindowsComponentsEnabled      = $RDSHost.Optimization.WindowsComponentsEnabled.ToString()
                                    $OPTWindowsServicesEnabled        = $RDSHost.Optimization.WindowsServicesEnabled.ToString()
                                    $OPTWinodwsScheduledTasksEnabled  = $RDSHost.Optimization.WindowsScheduledTasksEnabled.ToString()
                                    $OPTWindowsAdvancedOptionsEnabled = $RDSHost.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                    $OPTNetworkPerformanceEnabled     = $RDSHost.Optimization.NetworkPerformanceEnabled.ToString()
                                        $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)                                   $OPTRegistryEnabled               = $RDSHost.Optimization.RegistryEnabled.ToString()
                                    $OPTVisualEffectsEnabled          = $RDSHost.Optimization.VisualEffectsEnabled.ToString()   
                                    $OPTDiskCleanupEnabled            = $RDSHost.Optimization.DiskCleanupEnabled.ToString()
                                        $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])                                   $OPTCustomScriptEnabled           = $RDSHost.Optimization.CustomScriptEnabled.ToString()
                                            
                                        $RDSRestrictedUsers += $objUser.Value    
                                }                           }
                        }    
                                    
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSHost.InheritDefaultDesktopAccessSettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSHost.InheritDefaultUserProfileSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable optimization"; Value = $OPTEnableOptimization; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Optimization type"; Value = $OPTOptimizationType; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 250;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 5 0 "Windows Defender ATP:" $OPTWindowsDefenderATPEnabled
                                    If($OPTWindowsDefenderATPEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Defender ATP Optimizations"; Value = ""; }) > $Null
     
                                            If($RDSHost.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                            {
                                                    $ScriptInformation.Add(@{Data = "     Turn off Windows Defender ATP (I use my own ATP solution)"; Value = ""; }) > $Null
                                            }
                                            Else
                                            {
                                $ScriptInformation.Add(@{Data = "Restrict direct desktop access to the following users"; Value = $RDSRestrictDesktopAccess; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Turn on Windows Defender ATP and set process and folder exclusions"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Disable real-time protection"; Value = $RDSHost.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(); }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                                                  
                                $cnt = -1                                                   $cnt = -1
                                ForEach($Item in $RDSRestrictedUsers)                                                   ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeFolders)
                                {                                                   {
                                        $cnt++                                                           $cnt++
                                        If($cnt -eq 0)                                                           If($cnt -eq 0)
                                        {                                                           {
                                                                    $ScriptInformation.Add(@{Data = "     Exclude files and folders"; Value = $item; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                $ScriptInformation.Add(@{Data = "Users"; Value = $Item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                        }                                                           }
                                                    }
     
                                                    $cnt = -1
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                    {
                                                            $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "     Exclude processes"; Value = $item; }) > $Null
                                                            }
                                        Else                                                           Else
                                        {                                                           {
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                        }                                                           }
                                }                                                   }
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                    {
                                                            $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "     Exclude extensions"; Value = $item; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                            }
                                                    }
                                            }
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 250; <>                                         $Table.Columns.Item(1).Width = 250;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
     
                                    WriteWordLine 5 0 "Windows Components:" $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Components Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable (remove) components:"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            ForEach($item in $RDSHost.Optimization.WindowsComponents.WindowsComponentsList)
                                            {
                                                            If($Null -eq $item.DisplayName)
                                                            {
                                                                    $DisplayName = ""
                                                            }
                                                            Else
                                                            {
                                                                    $DisplayName = $item.DisplayName
                                                            }
                                                            If($Null -eq $item.ComponentName)
                                                            {
                                                                    $ComponentName = ""
                                                            }
                                                            Else
                                                            {
                                                                    $ComponentName = $item.ComponentName
                                                            }
                                                    $OptimizationTable += @{
                                                            DisplayName = $DisplayName
                                                            ComponentName = $ComponentName
                                                    }
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns DisplayName, ComponentName `
                                                    -Headers "Display name", "Component" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 200;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
     
                                    WriteWordLine 5 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Services Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable services:"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            ForEach($item in $RDSHost.Optimization.WindowsServices.WindowsServicesList)
                                            {
                                                            If($Null -eq $item.DisplayName)
                                                            {
                                                                    $DisplayName = ""
                                                            }
                                                            Else
                                                            {
                                                                    $DisplayName = $item.DisplayName
                                                            }
                                                            If($Null -eq $item.ServiceName)
                                                            {
                                                                    $Service = ""
                                                            }
                                                            Else
                                                            {
                                                                    $Service = $item.ServiceName
                                                            }
                                                            If($Null -eq $item.Aliases)
                                                            {
                                                                    $Aliases = ""
                                                            }
                                                            Else
                                                            {
                                                                    $Aliases = $item.Aliases
                                                            }
                                                    $OptimizationTable += @{
                                                            DisplayName = $DisplayName
                                                            Service     = $Service
                                                            Aliases     = $Aliases
                                                    }
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns DisplayName, Service, Aliases `
                                                    -Headers "Display name", "Service", "Aliases" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 100;
                                                    $Table.Columns.Item(3).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                    If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Scheduled Tasks Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable tasks:"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            ForEach($item in $RDSHost.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                            {
                                                            If($Null -eq $item.Task)
                                                            {
                                                                    $Task = ""
                                                            }
                                                            Else
                                                            {
                                                                    $Task = $item.Task
                                                            }
                                                            If($Null -eq $item.Type)
                                                            {
                                                                    $Type = ""
                                                            }
                                                            Else
                                                            {
                                                                    $Type = $item.Type.ToString()
                                                            }
                                                            If($Null -eq $item.Location)
                                                            {
                                                                    $Location = ""
                                                            }
                                                            Else
                                                            {
                                                                    $Location = $item.Location
                                                            }
                                                    $OptimizationTable += @{
                                                            Task     = $Task
                                                            Type     = $Type
                                                            Location = $Location
                                                    }
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Task, Type, Location `
                                                    -Headers "Task", "Type", "Location" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 250;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Advanced Options"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Disable Hibernate"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.Hibernate.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Telemetry collection"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.TeleCollection.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable System Restore"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.SystemRestore.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable error reporting to send additional data"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Tiles"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.Tiles.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Cortana digital assistant"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.Cortana.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Turn off Microsoft consumer experience"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Do not show Windows tips"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.WindowsTips.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Remove Common program groups from the Start Menu"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Partial Start Menu layout"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString()
                                                    Value   = $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled, Value `
                                                    -Headers "Setting", "Enabled", "Value" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 275;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 175;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTNetworkPerformanceEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Network Performance Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "FileInfoCacheEntriesMax"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString()
                                                    Value   = $RDSHost.Optimization.NetworkPerformance.FileInfoCache
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "DirectoryCacheEntriesMax"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString()
                                                    Value   = $RDSHost.Optimization.NetworkPerformance.DirCacheMax
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "FileNotFoundCacheEntriesMax"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString()
                                                    Value   = $RDSHost.Optimization.NetworkPerformance.FileNotFoundCache
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "DormantFileLimit"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString()
                                                    Value   = $RDSHost.Optimization.NetworkPerformance.DormantFileLimit
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable TCP/IP Task Offload"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DisableTCP.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable IPv6 Components"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable IPv6 to IPv4"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disables isatap for IPv6"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DisableIsaTap.ToString()
                                                    Value   = ""
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled, Value `
                                                    -Headers "Setting", "Enabled", "Value" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 150;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
     
                                    WriteWordLine 5 0 "Registry: " $OPTRegistryEnabled
                                    If($OPTRegistryEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Registry Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
     
                                            ForEach($item in $RDSHost.Optimization.Registry.RegistryList)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Data"; Value = $item.DWORDValue; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                            }
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 125;
                                            $Table.Columns.Item(2).Width = 375;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    
                                    WriteWordLine 5 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Visual Effects Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Animate controls and elements inside windows"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.AnimateControlSelectElements.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Animate windows when minimizing and maximizing"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Animations in the taskbar"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.AnimateTaskbar.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Enable Peek"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.EnablePeek.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Fade or slide menus into view"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.FadeSlideMenus.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Fade or slide Tooltips into view"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.FadeSlideToolTips.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Fade out menu items after clicking"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.FadeOutMenuItems.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Save taskbar thumbnail previews"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show shadows under mouse pointer"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.ShowShadowUnderMouse.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show shadows under windows"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.ShadowUnderWindows.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show thumbnails instead of icons"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show translucent selection rectangle"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.ShowTranslucentSelection.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show window contents while dragging"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Slide open combo boxes"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.SlideOpenComboBoxes.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Smooth edges of screen fonts"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Smooth-scroll list boxes"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.SmoothScrollListBoxes.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Use drop shadows for icon labels on the desktop"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.DropShadowsIcon.ToString()
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled `
                                                    -Headers "Setting", "Enabled" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 250;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Disk Cleanup Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Clean up redundant system files"
                                                    Enabled = $RDSHost.Optimization.DiskCleanup.CleanupSystemFiles.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Clean up the WinSxS Folder"
                                                    Enabled = $RDSHost.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Clean up temporary files and logs"
                                                    Enabled = $RDSHost.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Remove OneDrive"
                                                    Enabled = $RDSHost.Optimization.DiskCleanup.RemoveOneDrive.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Delete users' profiles"
                                                    Enabled = $RDSHost.Optimization.DiskCleanup.DeleteUserProfiles.ToString()
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled `
                                                    -Headers "Setting", "Enabled" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 175;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
     
                                    WriteWordLine 5 0 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Custom Script"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Command"; Value = $RDSHost.Optimization.CustomScript.Command; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Arguments"; Value = $RDSHost.Optimization.CustomScript.Arguments; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Initial directory"; Value = $RDSHost.Optimization.CustomScript.InitDir; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Username"; Value = $RDSHost.Optimization.CustomScript.User; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 100;
                                            $Table.Columns.Item(2).Width = 200;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                            }
                            If($Text)
                            {
                                    Line 4 "Inherit default settings`t: " $RDSHost.InheritDefaultOptimizationSettings.ToString()
                                    Line 4 "Enable optimization`t`t: " $OPTEnableOptimization
                                    Line 4 "Optimization type`t`t: " $OPTOptimizationType
                                    Line 4 "Category"
                                    
                                    Line 5 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                    If($OPTWindowsDefenderATPEnabled -eq "True")
                                    {
                                            Line 6 "Windows Defender ATP Optimizations"
                                            <#
                                                    WinDefATPTurnOffOn        : TurnOnWindowsDefenderATP
                                                    DisableRealTimeProtection : False
                                                    ExcludeFolders            : {%ProgramData%\Parallels\RASLogs\, %ProgramFiles(x86)%\Parallels\,
                                                                                                            %ProgramFiles%\Parallels\, %WINDOWS%\system32\config\...}
                                                    ExcludeProcesses          : {csrss.exe, winlogon.exe, rdpclip.exe, rdpinit.exe...}
                                                    ExcludeExtension          : {.vhd, .vhdx}                                       
                                            #>
                                            If($RDSHost.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                            {
                                                    Line 7 "Turn off Windows Defender ATP (I use my own ATP solution)"
                                            }
                                            Else
                                            {
                                                    Line 7 "Turn on Windows Defender ATP and set process and folder exclusions"
                                                    Line 7 "Disable real-time protection: " $RDSHost.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString()
                                                    Line 0 ""
                                                    Line 7 "Exclude files and folders:"
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                    {
                                                            Line 8 $item
                                                    }
     
                                                    Line 7 "Exclude processes:"
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                    {
                                                            Line 8 $item
                                                    }
                                                    
                                                    Line 7 "Exclude extensions:"
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                    {
                                                            Line 8 $item
                                                    }
                                            }
                                            
                                            Line 0 ""
                                    }
                                    
                                    Line 5 "Windows Components: " $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
                                    {
                                            Line 6 "Windows Components Optimizations"
                                            Line 7 "Disable (remove) components:"
                                            Line 0 ""
                                            Line 7 "Display name                                        Component                                         "
                                            Line 7 "======================================================================================================"
                                            #               12345678901234567890123456789012345678901234567890SS12345678901234567890123456789012345678901234567890
                                            #               Printing-XPSServices-Features                       SMB 1.0/CIFS File sharing support component
                                            <#
                                                              Type ComponentName                 DisplayName Aliases
                                                              ---- -------------                 ----------- -------
                                                    Predefined MSRDC-Infrastructure
                                                    Predefined MediaPlayback
                                                    Predefined WindowsMediaPlayer
                                                    Predefined Printing-XPSServices-Features
                                                    Predefined SMB1Protocol
                                                    Predefined SearchEngine-Client-Package
                                                    Predefined Xps-Foundation-Xps-Viewer                                    
                                            #>
                                            ForEach($item in $RDSHost.Optimization.WindowsComponents.WindowsComponentsList)
                                            {
                                                    Line 7 ( "{0,-50}  {1,-50}" -f $item.DisplayName, $item.ComponentName)
                                            }
                                            Line 0 ""
                                    }
                                    
                                    Line 5 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
                                    {
                                            Line 6 "Windows Services Optimizations"
                                            Line 7 "Disable services:"
                                            Line 0 ""
                                            Line 7 "Display name                                        Service                         Aliases             "
                                            Line 7 "========================================================================================================"
                                            #               12345678901234567890123456789012345678901234567890SS123456789012345678901234567890SS12345678901234567890
                                            #               Windows Media Player Network Sharing Service        TabletInputService              Superfecth
                                            <#
                                                              Type ServiceName        DisplayName Aliases
                                                              ---- -----------        ----------- -------
                                                    Predefined AJRouter
                                                    Predefined ALG
                                                    Predefined BTAGService
                                                    Predefined BthAvctpSvc
                                                    Predefined CscService
                                                    Predefined DOT3SVC
                                                    Predefined DPS
                                                    Predefined DiagTrack
                                                    Predefined EFS
                                                    Predefined FDResPub
                                                    Predefined MapsBroker
                                                    Predefined SSDPSRV
                                                    Predefined SensrSvc
                                                    Predefined SharedAccess
                                                    Predefined ShellHWDetection
                                                    Predefined StorSvc
                                                    Predefined Sysmain
                                                    Predefined Superfetch
                                                    Predefined TabletInputService
                                                    Predefined TapiSrv
                                                    Predefined Themes
                                                    Predefined WMPNetworkSvc
                                                    Predefined WbioSrvc
                                                    Predefined WdiSystemHost
                                                    Predefined WerSvc
                                                    Predefined bthserv
                                                    Predefined fdPHost
                                                    Predefined lfsvc
                                                    Predefined upnphost
                                                    Predefined wbengine
                                                    Predefined wisvc
                                                    Predefined wlidsvc                                      
                                            #>
                                            ForEach($item in $RDSHost.Optimization.WindowsServices.WindowsServicesList)
                                            {
                                                    Line 7 ( "{0,-50}  {1,-30}  {2,-20}" -f $item.DisplayName, $item.ServiceName, $item.Aliases)
                                            }
                                            Line 0 ""
                                    }
                                    
                                    Line 5 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                    If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                    {
                                            Line 6 "Windows Scheduled Tasks Optimizations"
                                            Line 7 "Disable tasks:"
                                            Line 0 ""
                                            Line 7 "Task                                                Type    Location                                          "
                                            Line 7 "=============================================================================================================="
                                            #               12345678901234567890123456789012345678901234567890SS123456SS12345678901234567890123456789012345678901234567890
                                            #               MNO Metadata Parser                                 Folder  \Microsoft\Windows\Mobile Broadband Accounts\
                                            <#
                                                    Task                Location                                        Type
                                                    ----                --------                                        ----
                                                    *                   \Microsoft\Windows\Application Experience     Folder
                                                    *                   \Microsoft\Windows\BitLocker                  Folder
                                                    CDSSync             \Microsoft\Windows\WlanSvc\                     Task
                                                    *                   \Microsoft\OneCore\DirectX                    Folder
                                                    GatherNetworkInfo   \Microsoft\Windows\NetTrace\                    Task
                                                    MNO Metadata Parser \Microsoft\Windows\Mobile Broadband Accounts\   Task
                                                    NotificationTask    \Microsoft\Windows\WwanSvc\                     Task
                                                    *                   \Microsoft\Office                             Folder
                                                    QueueReporting      \Microsoft\Windows\Windows Error Reporting\     Task
                                                    SR                  \Microsoft\Windows\SystemRestore\               Task
                                                    ScheduledDefrag     \Microsoft\Windows\Defrag\                      Task
                                                    Scheduled Start     \Microsoft\Windows\WindowsUpdate\               Task
                                                    *                   \Microsoft\Windows\Sysmain                    Folder
                                                    Tpm-HASCertRetr     \Microsoft\Windows\TPM\                         Task
                                                    Tpm-Maintenance     \Microsoft\Windows\TPM\                         Task
                                                    UninstallDeviceTask \Microsoft\Windows\Bluetooth\                   Task
                                                    UpdateLibrary       \Microsoft\Windows\Windows Media Sharing\       Task
                                                    *                   \Microsoft\Windows\Windows Defender           Folder
                                                    XblGameSaveTask     \Microsoft\XblGameSave\                         Task
                                                    sihpostreboot       \Microsoft\Windows\WindowsUpdate\               Task                                        
                                            #>
                                            ForEach($item in $RDSHost.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                            {
                                                    Line 7 ( "{0,-50}  {1,-6}  {2,-50}" -f $item.Task, $item.Type.ToString(), $item.Location)
                                            }
                                            Line 0 ""
                                    }
     
                                    Line 5 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                    {
                                            Line 6 "Windows Advanced Options"
                                            Line 0 ""
                                            Line 7 "Setting                                           Enabled  Value                                             "
                                            Line 7 "============================================================================================================="
                                            #               123456789012345678901234567890123456789012345678SS1234567SS12345678901234567890123456789012345678901234567890
                                            #               Remove Common program groups from the start menu  False    SomeConfigFile.xml
                                            <#
                                                    PartialStartLayoutContent   : Configuration.xml
                                                    Hibernate                   : True
                                                    TeleCollection              : True
                                                    SystemRestore               : True
                                                    AdditionalErrorReport       : True
                                                    Tiles                       : True
                                                    Cortana                     : True
                                                    MicrosoftConsumerExperience : True
                                                    WindowsTips                 : True
                                                    CommonProgramGroups         : True
                                                    PartialStartMenu            : True
                                            #>
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Hibernate", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.Hibernate.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Telemetry collection", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable System Restore", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable error reporting to send additional data", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Tiles", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.Tiles.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Cortana digital assistant", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.Cortana.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Turn off Microsoft consumer experience", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Do not show Windows tips", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Remove Common program groups from the Start Menu", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Partial Start Menu layout", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(), `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent)
                                            
                                            Line 0 ""
                                    }
     
                                    Line 5 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTNetworkPerformanceEnabled -eq "True")
                                    {
                                            Line 6 "Network Performance Optimizations"
                                            Line 0 ""
                                            Line 7 "Setting                      Enabled  Value"
                                            Line 7 "==========================================="
                                            #               123456789012345678901234567SS1234567SS12345
                                            #               FileNotFoundCacheEntriesMax  False    32768
                                            <#
                                                    DirCacheMax             : 4096
                                                    DormantFileLimit        : 256
                                                    FileNotFoundCache       : 32768
                                                    FileInfoCache           : 32768
                                                    FileInfoCacheEnable     : True
                                                    DirectoryCacheEnable    : True
                                                    FileNotFoundCacheEnable : True
                                                    DormantFileLimitEnable  : True
                                                    DisableTCP              : True
                                                    DisableIPv6CompEnable   : True
                                                    DisableIPv6ToIPv4       : True
                                                    DisableIsaTap           : True
                                            #>
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "FileInfoCacheEntriesMax", `
                                            $RDSHost.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(), `
                                            $RDSHost.Optimization.NetworkPerformance.FileInfoCache)
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "DirectoryCacheEntriesMax", `
                                            $RDSHost.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(), `
                                            $RDSHost.Optimization.NetworkPerformance.DirCacheMax)
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "FileNotFoundCacheEntriesMax", `
                                            $RDSHost.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(), `
                                            $RDSHost.Optimization.NetworkPerformance.FileNotFoundCache)
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "DormantFileLimit", `
                                            $RDSHost.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(), `
                                            $RDSHost.Optimization.NetworkPerformance.DormantFileLimit)
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable TCP/IP Task Offload", `
                                            $RDSHost.Optimization.NetworkPerformance.DisableTCP.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable IPv6 Components", `
                                            $RDSHost.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable IPv6 to IPv4", `
                                            $RDSHost.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disables isatap for IPv6", `
                                            $RDSHost.Optimization.NetworkPerformance.DisableIsaTap.ToString(), `
                                            "")
                                            
                                            Line 0 ""
                                    }
     
                                    Line 5 "Registry: " $OPTRegistryEnabled
                                    If($OPTRegistryEnabled -eq "True")
                                    {
                                            Line 6 "Registry Optimizations"
                                            Line 0 ""
                                            #               123456789012345678901234567SS1234567SS12345
                                            #               FileNotFoundCacheEntriesMax  False    32768
                                            <#
                                                    Id           : 1
                                                    Action       : Modify
                                                    RegistryName : ServicesPipeTimeout
                                                    DWORDValue   : 18000
                                                    DisplayName  : Increase service startup timeouts
                                                    HiveType     : HKEY_LOCAL_MACHINE
                                                    Path         : System\CurrentControlSet\Control
                                                    RegType      : REG_DWORD
     
                                                    Id           : 2
                                                    Action       : Modify
                                                    RegistryName : TimeOutValue
                                                    DWORDValue   : 200
                                                    DisplayName  : Increase Disk I/O Timeout
                                                    HiveType     : HKEY_LOCAL_MACHINE
                                                    Path         : System\CurrentControlSet\Services\Disk
                                                    RegType      : REG_DWORD
                                            #>
                                            Line 7 "Registry                                  Action  Value                 Type           Data                  Path                                                        "
                                            Line 7 "========================================================================================================================================================================="
                                            #               1234567890123456789012345678901234567890SS123456SS12345678901234567890SS1234567890123SS12345678901234567890SS123456789012345678901234567890123456789012345678901234567890
                                            #               Increase service startup timeouts         Modify  99999999999999999999  REG_EXPAND_SZ  99999999999999999999  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Disk
                                            ForEach($item in $RDSHost.Optimization.Registry.RegistryList)
                                            {
                                                    Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `
                                                    $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType, $item.DWORDValue, "$($item.HiveType)\$($item.Path)")
                                            }
                                            Line 0 ""
                                    }
     
                                    Line 5 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                    {
                                            Line 6 "Visual Effects Optimizations"
                                            Line 0 ""
                                            
                                            Switch ($RDSHost.Optimization.VisualEffects.VisualEffectsTypes)
                                            {
                                                    "LetWindowsChooseWhatsBest"     {$VisualEffectsType = "Let Windows choose what's best"; Break}
                                                    "AdjustForBestAppearnce"        {$VisualEffectsType = "Adjust for best appearance"; Break} #misspelled in the PoSH output and the docs
                                                    "AdjustForBestPerformance"      {$VisualEffectsType = "Adjust for best performance"; Break}
                                                    "Custom"                                        {$VisualEffectsType = "Custom"; Break}
                                                    Default                                         {$VisualEffectsType = "Unable to determine Visual Effects Optimization type: $($RDSHost.Optimization.VisualEffects.VisualEffectsTypes)"; Break}
                                            }
                                            Line 7 $VisualEffectsType
                                            Line 0 ""
                                            Line 7 "Setting                                             Enabled"
                                            Line 7 "==========================================================="
                                            #               12345678901234567890123456789012345678901234567890SS1234567
                                            #               Use drop shadows for icon labels on the desktop     False  
                                            <#
                                                    VisualEffectsTypes                     : Custom
                                                    AnimateControlSelectElements           : False
                                                    AnimateWindowsWhenMinimizingMaximizing : False
                                                    AnimateTaskbar                         : False
                                                    EnablePeek                             : False
                                                    FadeSlideMenus                         : False
                                                    FadeSlideToolTips                      : False
                                                    FadeOutMenuItems                       : False
                                                    SaveTaskbarThumbnail                   : False
                                                    ShowShadowUnderMouse                   : False
                                                    ShadowUnderWindows                     : False
                                                    ThumbnailsInsteadOfIcons               : False
                                                    ShowTranslucentSelection               : False
                                                    ShowWindowsContentWhilstDragging       : False
                                                    SlideOpenComboBoxes                    : False
                                                    SmoothEdgesScreenFonts                 : True
                                                    SmoothScrollListBoxes                  : False
                                                    DropShadowsIcon                        : False
                                            #>
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Animate controls and elements inside windows", `
                                            $RDSHost.Optimization.VisualEffects.AnimateControlSelectElements.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Animate windows when minimizing and maximizing", `
                                            $RDSHost.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Animations in the taskbar", `
                                            $RDSHost.Optimization.VisualEffects.AnimateTaskbar.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Enable Peek", `
                                            $RDSHost.Optimization.VisualEffects.EnablePeek.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Fade or slide menus into view", `
                                            $RDSHost.Optimization.VisualEffects.FadeSlideMenus.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Fade or slide Tooltips into view", `
                                            $RDSHost.Optimization.VisualEffects.FadeSlideToolTips.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Fade out menu items after clicking", `
                                            $RDSHost.Optimization.VisualEffects.FadeOutMenuItems.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Save taskbar thumbnail previews", `
                                            $RDSHost.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Show shadows under mouse pointer", `
                                            $RDSHost.Optimization.VisualEffects.ShowShadowUnderMouse.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Show shadows under windows", `
                                            $RDSHost.Optimization.VisualEffects.ShadowUnderWindows.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Show thumbnails instead of icons", `
                                            $RDSHost.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Show translucent selection rectangle", `
                                            $RDSHost.Optimization.VisualEffects.ShowTranslucentSelection.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Show window contents while dragging", `
                                            $RDSHost.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Slide open combo boxes", `
                                            $RDSHost.Optimization.VisualEffects.SlideOpenComboBoxes.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Smooth edges of screen fonts", `
                                            $RDSHost.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Smooth-scroll list boxes", `
                                            $RDSHost.Optimization.VisualEffects.SmoothScrollListBoxes.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Use drop shadows for icon labels on the desktop", `
                                            $RDSHost.Optimization.VisualEffects.DropShadowsIcon.ToString())
                                            
                                            Line 0 ""
                                    }
     
                                    Line 5 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                    {
                                            Line 6 "Disk Cleanup Optimizations"
                                            Line 0 ""
                                            
                                            Line 7 "Setting                            Enabled"
                                            Line 7 "=========================================="
                                            #               123456789012345678901234567890123SS1234567
                                            #               Clean up temporary files and logs  False  
                                            <#
                                                    CleanupWinSxSFolder      : False
                                                    CleanupSystemFiles       : False
                                                    CleanupTemporaryFileLogs : True
                                                    RemoveOneDrive           : False
                                                    DeleteUserProfiles       : False
                                            #>
                                            Line 7 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up redundant system files", `
                                            $RDSHost.Optimization.DiskCleanup.CleanupSystemFiles.ToString())
                                            
                                            Line 7 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up the WinSxS Folder", `
                                            $RDSHost.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString())
                                            
                                            Line 7 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up temporary files and logs", `
                                            $RDSHost.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString())
                                            
                                            Line 7 ( "{0,-33}  {1,-7}" -f `
                                            "Remove OneDrive", `
                                            $RDSHost.Optimization.DiskCleanup.RemoveOneDrive.ToString())
                                            
                                            Line 7 ( "{0,-33}  {1,-7}" -f `
                                            "Delete users' profiles", `
                                            $RDSHost.Optimization.DiskCleanup.DeleteUserProfiles.ToString())
                                            
                                            Line 0 ""
                                    }
     
                                    Line 5 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled  -eq "True")
                                    {
                                            Line 6 "Custom Script"
                                            Line 0 ""
                                            
                                            <#
                                                    Arguments : CustomScriptArguments
                                                    Command   : CustomScriptCommand
                                                    InitDir   : CustomScriptInitialDirectory
                                                    User      : CustomScriptUsername
                                            #>
                                            Line 7 "Command`t`t : " $RDSHost.Optimization.CustomScript.Command
                                            Line 7 "Arguments`t : " $RDSHost.Optimization.CustomScript.Arguments
                                            Line 7 "Initial directory: " $RDSHost.Optimization.CustomScript.InitDir
                                            Line 7 "Username`t : " $RDSHost.Optimization.CustomScript.User
                                            Line 0 ""
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Inherit default settings:",($Script:htmlsb),$RDSHost.InheritDefaultOptimizationSettings.ToString(),$htmlwhite)
                                    $rowdata += @(,("Enable optimization",($Script:htmlsb), $OPTEnableOptimization,$htmlwhite))
                                    $rowdata += @(,("Optimization type",($Script:htmlsb), $OPTOptimizationType,$htmlwhite))
     
                                    $msg = "Optimization"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 4 0 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                    If($OPTWindowsDefenderATPEnabled -eq "True")
                                    {
                                            $rowdata = @()
                                            $columnHeaders = @("Windows Defender ATP Optimizations",($Script:htmlsb),"",$htmlwhite)
     
                                            If($RDSHost.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                            {
                                                    $rowdata += @(,("     Turn off Windows Defender ATP (I use my own ATP solution)",($Script:htmlsb), "",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("     Turn on Windows Defender ATP and set process and folder exclusions",($Script:htmlsb), "",$htmlwhite))
                                                    $rowdata += @(,("     Disable real-time protection",($Script:htmlsb), $RDSHost.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(),$htmlwhite))
                                                    $rowdata += @(,("",($Script:htmlsb), "",$htmlwhite))
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                    {
                                                            $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $rowdata += @(,("     Exclude files and folders",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                    }
     
                                                    $cnt = -1
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                    {
                                                            $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $rowdata += @(,("     Exclude processes",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                    }
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                    {
                                                            $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $rowdata += @(,("     Exclude extensions",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                    }
                                            }
     
     
                                            $msg = ""
                                            $columnWidths = @("300","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows Components: " $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Windows Components Optimizations"
     
                                            $rowdata = @()
     
                                            ForEach($item in $RDSHost.Optimization.WindowsComponents.WindowsComponentsList)
                                            {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.ComponentName,$htmlwhite)
                                                    )
                                            }
     
                                            $columnHeaders = @(
                                                    "Display Name",($Script:htmlsb),
                                                    "Component",($Script:htmlsb)
                                            )
     
                                            $msg = "Disable (remove) components:"
                                            $columnWidths = @("200","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Windows Services Optimizations"
     
                                            $rowdata = @()
     
                                            ForEach($item in $RDSHost.Optimization.WindowsServices.WindowsServicesList)
                                            {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.ServiceName,$htmlwhite,
                                                            $item.Aliases,$htmlwhite)
                                                    )
                                            }
     
                                            $columnHeaders = @(
                                                    "Display Name",($Script:htmlsb),
                                                    "Service",($Script:htmlsb),
                                                    "Aliases",($Script:htmlsb)
                                            )
     
                                            $msg = "Disable services:"
                                            $columnWidths = @("200","100","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled
                                    If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Windows Scheduled Tasks Optimizations"
     
                                            $rowdata = @()
     
                                            ForEach($item in $RDSHost.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                            {
                                                    $rowdata += @(,(
                                                            $item.Task,$htmlwhite,
                                                            $item.Type.Tostring(),$htmlwhite,
                                                            $item.Location,$htmlwhite)
                                                    )
                                            }
     
                                            $columnHeaders = @(
                                                    "Task",($Script:htmlsb),
                                                    "Type",($Script:htmlsb),
                                                    "Location",($Script:htmlsb)
                                            )
     
                                            $msg = "Disable tasks:"
                                            $columnWidths = @("200","50","250")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Windows Advanced Options"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Disable Hibernate",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.Hibernate.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Telemetry collection",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable System Restore",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable error reporting to send additional data",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Tiles",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.Tiles.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Cortana digital assistant",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.Cortana.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Turn off Microsoft consumer experience",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Do not show Windows tips",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Remove Common program groups from the Start Menu",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Partial Start Menu layout",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(),$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent,$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb),
                                                    "Value",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("300","50","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Network Performance Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "FileInfoCacheEntriesMax",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(),$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.FileInfoCache,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "DirectoryCacheEntriesMax",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(),$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DirCacheMax,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "FileNotFoundCacheEntriesMax",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(),$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.FileNotFoundCache,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "DormantFileLimit",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(),$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DormantFileLimit,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable TCP/IP Task Offload",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DisableTCP.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable IPv6 Components",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable IPv6 to IPv4",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disables isatap for IPv6",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DisableIsaTap.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb),
                                                    "Value",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("170","50","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Registry: " $OPTRegistryEnabled       
                                    If($OPTRegistryEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Registry Optimizations"
     
                                            $rowdata = @()
     
                                            ForEach($item in $RDSHost.Optimization.Registry.RegistryList)
                                            {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.Action,$htmlwhite,
                                                            $item.RegistryName,$htmlwhite,
                                                            $item.RegType,$htmlwhite,
                                                            $item.DWORDValue,$htmlwhite,
                                                            "$($item.HiveType)\$($item.Path)",$htmlwhite)
                                                    )
                                            }
     
                                            $columnHeaders = @(
                                                    "Registry",($Script:htmlsb),
                                                    "Action",($Script:htmlsb),
                                                    "Value",($Script:htmlsb),
                                                    "Type",($Script:htmlsb),
                                                    "Data",($Script:htmlsb),
                                                    "Path",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("200","50","100","100","100","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Visual Effects Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Animate controls and elements inside windows",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.AnimateControlSelectElements.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Animate windows when minimizing and maximizing",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Animations in the taskbar",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.AnimateTaskbar.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Enable Peek",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.EnablePeek.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade or slide menus into view",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.FadeSlideMenus.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade or slide Tooltips into view",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.FadeSlideToolTips.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade out menu items after clicking",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.FadeOutMenuItems.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Save taskbar thumbnail previews",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show shadows under mouse pointer",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.ShowShadowUnderMouse.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show shadows under windows",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.ShadowUnderWindows.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show thumbnails instead of icons",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show translucent selection rectangle",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.ShowTranslucentSelection.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show window contents while dragging",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Slide open combo boxes",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.SlideOpenComboBoxes.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Smooth edges of screen fonts",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Smooth-scroll list boxes",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.SmoothScrollListBoxes.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Use drop shadows for icon labels on the desktop",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.DropShadowsIcon.ToString(),$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("275","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Disk Cleanup Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Clean up redundant system files",$htmlwhite,
                                                    $RDSHost.Optimization.DiskCleanup.CleanupSystemFiles.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Clean up the WinSxS Folder",$htmlwhite,
                                                    $RDSHost.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Clean up temporary files and logs",$htmlwhite,
                                                    $RDSHost.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Remove OneDrive",$htmlwhite,
                                                    $RDSHost.Optimization.DiskCleanup.RemoveOneDrive.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Delete users' profiles",$htmlwhite,
                                                    $RDSHost.Optimization.DiskCleanup.DeleteUserProfiles.ToString(),$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("200","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled -eq "True")
                                    {
                                            $rowdata = @()
                                            $columnHeaders = @("Custom Script",($Script:htmlsb),"",$htmlwhite)
                                            $rowdata += @(,("     Command",($Script:htmlsb), $RDSHost.Optimization.CustomScript.Command,$htmlwhite))
                                            $rowdata += @(,("     Arguments",($Script:htmlsb), $RDSHost.Optimization.CustomScript.Arguments,$htmlwhite))
                                            $rowdata += @(,("     Initial directory",($Script:htmlsb), $RDSHost.Optimization.CustomScript.InitDir,$htmlwhite))
                                            $rowdata += @(,("     Username",($Script:htmlsb), $RDSHost.Optimization.CustomScript.User,$htmlwhite))
     
                                            $msg = ""
                                            $columnWidths = @("125","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
                            }
     
                            #Desktop Access
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Desktop access"
                            }
                            If($Text)
                            {
                                    Line 3 "Desktop access"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($RDSHost.InheritDefaultDesktopAccessSettings)
                            {
                                    #do we inherit group or site defaults?
                                    #is this RDS host in a group?
                                    #http://woshub.com/hot-to-convert-sid-to-username-and-vice-versa/
                                    #for translating the User SID to the AD user name
                                    $Results = Get-RASRDSGroup -SiteId $Site.Id -EA 0 4>$Null
                                    
                                    If($? -and $Null -ne $Results)
                                    {
                                            If($Results.RDSIds -Contains $RDSHost.Id )
                                            {
                                                    #does this group inherit default settings?
                                                    If($Results.InheritDefaultDesktopAccessSettings -eq $False)
                                                    {
                                                            #no we don't, so get the default settings for the group
                                                            $GroupDefaults = $Results.RDSDefSettings
     
                                                            $RDSRestrictDesktopAccess = $GroupDefaults.RestrictDesktopAccess.ToString()
                                                            $RDSRestrictedUsers       = @()
                                                            
                                                            ForEach($User in $GroupDefaults.RestrictedUsers)
                                                            {
                                                                    $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                                                    $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                                                    
                                                                    $RDSRestrictedUsers += $objUser.Value
                                                            }
                                                    }
                                                    Else
                                                    {
                                                            #yes we do, get the default settings for the Site
                                                            #use the Site default settings
                                                            $RDSDefaults = Get-RASRDSDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $RDSDefaults)
                                                            {
                                                                    $RDSRestrictDesktopAccess = $RDSDefaults.RestrictDesktopAccess.ToString()
                                                                    $RDSRestrictedUsers       = @()
                                                                    
                                                                    ForEach($User in $RDSDefaults.RestrictedUsers)
                                                                    {
                                                                            $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                                                            $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                                                            
                                                                            $RDSRestrictedUsers += $objUser.Value
                                                                    }
                                                            }
                                                            Else
                                                            {
                                                                    #unable to retrieve default, use built-in default values
                                                                    $RDSRestrictDesktopAccess = "False"
                                                                    $RDSRestrictedUsers       = @()
                                                            }
                                                    }
                                            }
                                    }
                                    Else
                                    {
                                            #RDS Host is not in a group
                                            #get the settings for the host
                                            $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString()
                                            $RDSRestrictedUsers       = @()
                                            
                                            ForEach($User in $RDSHost.RestrictedUsers)
                                            {
                                                    $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                                    $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                                    
                                                    $RDSRestrictedUsers += $objUser.Value
                                            }
                                    }
                            }
                            Else
                            {
                                    #we don't inherit
                                    #get the settings for the host
                                    $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString()
                                    $RDSRestrictedUsers       = @()
                                    
                                    ForEach($User in $RDSHost.RestrictedUsers)
                                    {
                                            $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                            $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                            
                                            $RDSRestrictedUsers += $objUser.Value
                                    }
                            }
                                    
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSHost.InheritDefaultDesktopAccessSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Restrict direct desktop access to the following users"; Value = $RDSRestrictDesktopAccess; }) > $Null
                                    
                                    $cnt = -1
                                    ForEach($Item in $RDSRestrictedUsers)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Users"; Value = $Item; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 250;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
 
  -+                                                         $RDSRemoveClientNameFromPrinter          = $GroupDefaults.RemoveClientNameFromPrinterName.ToString()
 
  -+                                                                 $RDSRemoveClientNameFromPrinter          = $RDSDefaults.RemoveClientNameFromPrinterName.ToString()
 
  -+                                                                 $RDSRemoveClientNameFromPrinter          = "False"
 
  -+                                         $RDSRemoveClientNameFromPrinter          = $RDSHost.RemoveClientNameFromPrinterName.ToString()
 
  -+                                 $RDSRemoveClientNameFromPrinter    = $RDSHost.RemoveClientNameFromPrinterName.ToString()
 
  -+                                 If($RDSHost.RemoveSessionNumberFromPrinterName)
                                    {
                                            $ScriptInformation.Add(@{Data = "Remove client name from printer name"; Value = $RDSRemoveClientNameFromPrinter; }) > $Null
                                    }
 
  -+                                 If($RDSHost.RemoveSessionNumberFromPrinterName)
                                    {
                                            Line 4 "Remove client name from printer name`t`t`t: " $RDSRemoveClientNameFromPrinter
                                    }
 
  -+                                 If($RDSHost.RemoveSessionNumberFromPrinterName)
                                    {
                                            $rowdata += @(,("Remove client name from printer name",($Script:htmlsb),$RDSRemoveClientNameFromPrinter,$htmlwhite))
                                    }
 
  -+                         
                            #Get the agent state for the group
                            $RDSGroupStatus = Get-RASRDSGroupStatus -Name $RDSGroup.Name -EA 0 4>$Null
                            
                            If(!$? -or $Null -eq $RDSGroupStatus)
                            {
                                    $RDSGroupAgentState = "Unknown"
                            }
                            Else
                            {
                                    $RDSGroupAgentState = GetRASStatus $RDSGroupStatus.AgentState
                            }
                            
 
  -+                                 $ScriptInformation.Add(@{Data = "Status"; Value = $RDSGroupAgentState; }) > $Null
 
  -+                                 Line 2 "Status`t`t`t: " $RDSGroupAgentState
 
  -+                                 $rowdata += @(,("Status",($Script:htmlsb),$RDSGroupAgentState,$htmlwhite))
 
  <>  
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 250;
                                    $Table.Columns.Item(2).Width = 250;
     
                                $ScriptInformation.Add(@{Data = "RD session hosts based on a template"; Value = $RDSGroup.UseRASTemplate; }) > $Null                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Enable Group in site`t: " $RDSGroup.Enabled.ToString()
                                    Line 3 "Name`t`t`t: " $RDSGroup.Name
                                    Line 3 "Description`t`t: " $RDSGroup.Description
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                $ScriptInformation.Add(@{Data = "RAS template"; Value = $RDSGroup.RASTemplateId; }) > $Null                                   $columnHeaders = @("Enable Group in site",($Script:htmlsb),$RDSGroup.Enabled.ToString(),$htmlwhite)
                                    $rowdata += @(,("Name",($Script:htmlsb),$RDSGroup.Name,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$RDSGroup.Description,$htmlwhite))
     
                                    $msg = "General"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            #Servers
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Servers"
                            }
                            If($Text)
                            {
                                    Line 2 "Servers"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
 
                                        $ScriptInformation.Add(@{Data = "Group Members"; Value = ""; }) > $Null +-  
 
  <>                                                 If($RDSGroupMember.Enabled)
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Enabled"
                                                    }
                                                    Else
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Disabled"
                                                    }
                                                    
                                                    $Status = Get-RASRDSStatus -Server $RDSGroupMember.Server  -EA 0 4>$Null
                                                    
                                                    If($? -and $Null -ne $Status)
                                                    {
                                                            $AgentStatus = GetRASStatus $Status.AgentState
                                                $cnt++                                                           $cnt++
                                                $ScriptInformation.Add(@{Data = "     Member"; Value = $RDSGroupMember.Server; }) > $Null                                                           $ScriptInformation.Add(@{Data = "Server"; Value = $RDSGroupMember.Server; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Logon status"; Value = $RDSGroupMember.Enabled.ToString(); }) > $Null                                                           $ScriptInformation.Add(@{Data = "Status"; Value = $AgentStatus; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Type"; Value = "Server"; }) > $Null                                                           $ScriptInformation.Add(@{Data = "Logon status"; Value = $RDSGroupMemberLogonStatus; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Description"; Value = $RDSGroupMember.Description; }) > $Null                                                           $ScriptInformation.Add(@{Data = "Description"; Value = $RDSGroupMember.Description; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Sessions"; Value = $Status.ActiveSessions.ToString(); }) > $Null
                                                If($RDSGroupMembers.Count -gt 1)                                                           If($RDSGroupMembers.Count -gt 1)
                                                {                                                           {
                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                            }
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = "Server"; Value = "Error retrieving server $($RDSGroupMember.Server) status"; }) > $Null
 
                                Line 3 "Enable Group in site`t`t`t: " $RDSGroup.Enabled.ToString() +-  
                                Line 3 "Name`t`t`t`t`t: " $RDSGroup.Name    
                                Line 3 "Description`t`t`t`t: " $RDSGroup.Description    
                                Line 3 "RD session hosts based on a template`t: " $RDSGroup.UseRASTemplate    
                                Line 3 "RAS template`t`t`t`t: " $RDSGroup.RASTemplateId    
 
                                        Line 3 "Group Members" "" +-  
 
  <>                                                 If($RDSGroupMember.Enabled)
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Enabled"
                                                    }
                                                    Else
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Disabled"
                                                    }
                                                            
                                                    $Status = Get-RASRDSStatus -Server $RDSGroupMember.Server  -EA 0 4>$Null
                                                            
                                                    If($? -and $Null -ne $Status)
                                                    {
                                                            $AgentStatus = GetRASStatus $Status.AgentState
                                                $cnt++                                                           $cnt++
                                                Line 4 "Member`t`t: " $RDSGroupMember.Server                                                           Line 3 "Server`t`t: " $RDSGroupMember.Server
                                                            Line 3 "Status`t`t: " $AgentStatus
                                                Line 4 "Logon status`t: " $RDSGroupMember.Enabled.ToString()                                                           Line 3 "Logon status`t: " $RDSGroupMemberLogonStatus
                                                Line 4 "Type`t`t: " "Server"    
                                                Line 4 "Description`t: " $RDSGroupMember.Description                                                           Line 3 "Description`t: " $RDSGroupMember.Description
                                                            Line 3 "Sessions`t: " $Status.ActiveSessions.ToString()
                                                If($RDSGroupMembers.Count -gt 1)                                                           If($RDSGroupMembers.Count -gt 1)
                                                {                                                           {
                                                        Line 4 ""                                                                   Line 3 ""
                                                            }
                                                    }
                                                    Else
                                                    {
                                                            Line 3 "Server`t`t: " "Error retrieving server $($RDSGroupMember.Server) status"
 
                                $columnHeaders = @("Enable Group in site",($Script:htmlsb),$RDSGroup.Enabled.ToString(),$htmlwhite) +-  
                                $rowdata += @(,("Name",($Script:htmlsb),$RDSGroup.Name,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$RDSGroup.Description,$htmlwhite))    
                                $rowdata += @(,("RD session hosts based on a template",($Script:htmlsb),$RDSGroup.UseRASTemplate.ToString(),$htmlwhite))    
                                $rowdata += @(,("RAS template",($Script:htmlsb),$RDSGroup.RASTemplateId.ToString(),$htmlwhite))    
 
                                        $rowdata += @(,("Group Members",($Script:htmlsb),"",$htmlwhite)) +-  
 
  <>                                                 If($RDSGroupMember.Enabled)
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Enabled"
                                                    }
                                                    Else
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Disabled"
                                                    }
                                                            
                                                    $Status = Get-RASRDSStatus -Server $RDSGroupMember.Server  -EA 0 4>$Null
                                                    
                                                    If($? -and $Null -ne $Status)
                                                    {
                                                            $AgentStatus = GetRASStatus $Status.AgentState
                                                $cnt++                                                           $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $columnHeaders = @("Member",($Script:htmlsb),$RDSGroupMember.Server,$htmlwhite)
                                                            }
                                                            Else
                                                            {
                                                $rowdata += @(,("     Member",($Script:htmlsb),$RDSGroupMember.Server,$htmlwhite))                                                                   $rowdata += @(,("Member",($Script:htmlsb),$RDSGroupMember.Server,$htmlwhite))
                                                            }
                                                $rowdata += @(,("     Logon status",($Script:htmlsb),$RDSGroupMember.Enabled.ToString(),$htmlwhite))                                                           $rowdata += @(,("Status",($Script:htmlsb),$AgentStatus,$htmlwhite))
                                                $rowdata += @(,("     Type",($Script:htmlsb),"Server",$htmlwhite))                                                           $rowdata += @(,("Logon status",($Script:htmlsb),$RDSGroupMemberLogonStatus,$htmlwhite))
                                                $rowdata += @(,("     Description",($Script:htmlsb),$RDSGroupMember.Description,$htmlwhite))                                                           $rowdata += @(,("Description",($Script:htmlsb),$RDSGroupMember.Description,$htmlwhite))
                                                            $rowdata += @(,("Sessions",($Script:htmlsb),$Status.ActiveSessions.ToString(),$htmlwhite))
                                                If($RDSGroupMembers.Count -gt 1)                                                           If($RDSGroupMembers.Count -gt 1)
                                                {                                                           {
                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                            }
 
  -+                                                 Else
                                                    {
                                                            $rowdata += @(,("Server",($Script:htmlsb),"Error retrieving server $($RDSGroupMember.Server) status",$htmlwhite))
                                                    }
 
                                $msg = "General" <>                                 $msg = "Servers"
 
                                                "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                                 "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
                                                "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                                   "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
                                                "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                                   "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                     $ReplaceRegisteredApplication = "True";
                                                                                                                     Break}
                                                Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)"; Break}                                                   Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
 
                                                "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                                 "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                                   "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                                    $RDSAllowDragAndDrop = "False";
                                                    Break}
                                                "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                                   "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                                   "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)"; Break}                                                   Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)";
                                                    $RDSAllowDragAndDrop = "False";
                                                    Break}
 
                                        If($RDSDefaults.PreferredPAId -eq 0) <>                                         If($RDSDefaults.PreferredBrokerId -eq 0)
 
                                                $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSDefaults.PreferredPAId -EA 0 4>$Null).Server <>                                                 $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSDefaults.PreferredBrokerId -EA 0 4>$Null).Server
 
  -+                                         $ReplaceRegisteredApplication          = "False"
 
  -+                                         $RDSAllowDragAndDrop                   = "True"
 
                                        "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                         "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                        "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                           "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                        "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                           "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                             $ReplaceRegisteredApplication = "True";
                                                                                                             Break}
                                        Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSGroup.AllowURLAndMailRedirection)"; Break}                                           Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSGroupDefaults.AllowURLAndMailRedirection)";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
 
                                        "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                         "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                           "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                            $RDSAllowDragAndDrop = "False";
                                            Break}
                                        "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                           "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                           "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSGroup.DragAndDropMode)"; Break}                                           Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSGroupDefaults.DragAndDropMode)";
                                            $RDSAllowDragAndDrop = "False";
                                            Break}
 
                                If($RDSGroupDefaults.PreferredPAId -eq 0) <>                                 If($RDSGroupDefaults.PreferredBrokerId -eq 0)
 
                                        $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSGroupDefaults.PreferredPAId -EA 0 4>$Null).Server <>                                         $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSGroupDefaults.PreferredBrokerId -EA 0 4>$Null).Server
 
  <>                                 $ScriptInformation.Add(@{Data = "Application session lingering"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Disconnect active session after"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Logoff disconnected session after"; Value = $RDSPublishingSessionResetTime; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Other settings"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "Port"; Value = $RDSPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Port"; Value = $RDSPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Max Sessions"; Value = $RDSMaxSessions; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Max Sessions"; Value = $RDSMaxSessions; }) > $Null
                                $ScriptInformation.Add(@{Data = "Publishing Session Disconnect Timeout"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Publishing Session Reset Timeout"; Value = $RDSPublishingSessionResetTime; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Preferred Connection Broker"; Value = $RDSPreferredPublishingAgent; }) > $Null
 
  <>                                 $ScriptInformation.Add(@{Data = "     Replace registered application"; Value = $ReplaceRegisteredApplication; }) > $Null
                                $ScriptInformation.Add(@{Data = "Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null
                                $ScriptInformation.Add(@{Data = "Drag and drop"; Value = $RDSDragAndDrop; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable Drag and drop"; Value = $RDSAllowDragandDrop; }) > $Null
                                $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $RDSPreferredPublishingAgent; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSDragAndDrop; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Allow file transfer command (HTML5 and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Allow file transfer command (Web (HTML5) and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null
                                $ScriptInformation.Add(@{Data = "Configure File Transfer"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Configure File Transfer"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSFileTransferMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Direction"; Value = $RDSFileTransferMode; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Location"; Value = $RDSFileTransferLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Location"; Value = $RDSFileTransferLocation; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable drive redirection cache"; Value = $RDSEnableDriveRedirectionCache; }) > $Null
 
                                Line 3 "Inherit default settings`t`t`t`t: " $RDSGroup.InheritDefaultAgentSettings.ToString() <>                                 Line 3 "Inherit default settings`t`t`t`t`t: " $RDSGroup.InheritDefaultAgentSettings.ToString()
                                    Line 3 "Application session lingering"
                                    Line 4 "Disconnect active session after`t`t`t`t: " $RDSPublishingSessionDisconnectTimeout
                                    Line 4 "Logoff disconnected session after`t`t`t: " $RDSPublishingSessionResetTime
                                    Line 3 "Other settings"
                                Line 3 "Port`t`t`t`t`t`t`t: " $RDSPort                                   Line 4 "Port`t`t`t`t`t`t`t: " $RDSPort
                                Line 3 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions                                   Line 4 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions
                                Line 3 "Publishing Session Disconnect Timeout`t`t`t: " $RDSPublishingSessionDisconnectTimeout    
                                Line 3 "Publishing Session Reset Timeout`t`t`t: " $RDSPublishingSessionResetTime                                   Line 4 "Preferred Connection Broker`t`t`t`t: " $RDSPreferredPublishingAgent
                                Line 3 "Allow Client URL/Mail Redirection`t`t`t: " $RDSAllowClientURLMailRedirection                                   Line 3 "Allow Client URL/Mail Redirection`t`t`t`t: " $RDSAllowClientURLMailRedirection
                                    Line 4 "Replace registered application`t`t`t`t: " $ReplaceRegisteredApplication
                                Line 3 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject                                   Line 4 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject
                                Line 3 "Drag and drop`t`t`t`t`t`t: " $RDSDragAndDrop                                   Line 3 "Enable Drag and drop`t`t`t`t`t`t: " $RDSAllowDragandDrop
                                Line 3 "Preferred Publishing Agent`t`t`t`t: " $RDSPreferredPublishingAgent                                   Line 4 "Direction`t`t`t`t`t`t: " $RDSDragAndDrop
                                Line 3 "Allow 2xRemoteExec to send command to the client`t: " $RDSAllowRemoteExec                                   Line 3 "Allow 2xRemoteExec to send command to the client`t`t: " $RDSAllowRemoteExec
                                Line 3 "Use RemoteApp if available`t`t`t`t: " $RDSUseRemoteApps                                   Line 3 "Use RemoteApp if available`t`t`t`t`t: " $RDSUseRemoteApps
                                Line 3 "Enable applications monitoring`t`t`t`t: " $RDSEnableAppMonitoring                                   Line 3 "Enable applications monitoring`t`t`t`t`t: " $RDSEnableAppMonitoring
                                Line 3 "Allow file transfer command (HTML5 and Chrome clients)`t: " $RDSAllowFileTransfer                                   Line 3 "Allow file transfer command (Web (HTML5) and Chrome clients)`t: " $RDSAllowFileTransfer
                                Line 3 "Configure File Transfer"                                   Line 4 "Configure File Transfer"
                                Line 4 "Direction`t`t`t: " $RDSFileTransferMode                                   Line 5 "Direction`t`t`t: " $RDSFileTransferMode
                                Line 4 "Location`t`t`t: " $RDSFileTransferLocation                                   Line 5 "Location`t`t`t: " $RDSFileTransferLocation
                                Line 4 "Do not allow to change location`t: " $RDSFileTransferChangeLocation                                   Line 5 "Do not allow to change location : " $RDSFileTransferChangeLocation
                                    Line 3 "Enable drive redirection cache`t`t`t`t`t: " $RDSEnableDriveRedirectionCache
 
  <>                                 $rowdata += @(,("Application session lingering",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("     Disconnect active session after",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))
                                    $rowdata += @(,("     Logoff disconnected session after",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))
                                    $rowdata += @(,("Other settings",($Script:htmlsb),$RDSPort,$htmlwhite))
                                $rowdata += @(,("Port",($Script:htmlsb),$RDSPort,$htmlwhite))                                   $rowdata += @(,("     Port",($Script:htmlsb),$RDSPort,$htmlwhite))
                                $rowdata += @(,("Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))                                   $rowdata += @(,("     Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))
                                $rowdata += @(,("Publishing Session Disconnect Timeout",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))    
                                $rowdata += @(,("Publishing Session Reset Timeout",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))                                   $rowdata += @(,("     Preferred Connection Broker",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))
 
  <>                                 $rowdata += @(,("     Replace registered application",($Script:htmlsb),$ReplaceRegisteredApplication,$htmlwhite))
                                $rowdata += @(,("Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))                                   $rowdata += @(,("     Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))
                                $rowdata += @(,("Drag and drop",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))                                   $rowdata += @(,("Enable Drag and drop",($Script:htmlsb),$RDSAllowDragandDrop,$htmlwhite))
                                $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))                                   $rowdata += @(,("     Direction",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))
 
                                $rowdata += @(,("Allow file transfer command (HTML5 and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite)) <>                                 $rowdata += @(,("Allow file transfer command (Web (HTML5) and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite))
                                $rowdata += @(,("Configure File Transfer",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Configure File Transfer",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("     Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))                                   $rowdata += @(,("          Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))
                                $rowdata += @(,("     Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))                                   $rowdata += @(,("          Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))
                                $rowdata += @(,("     Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))                                   $rowdata += @(,("          Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))
                                    $rowdata += @(,("Enable drive redirection cache",($Script:htmlsb),$RDSEnableDriveRedirectionCache,$htmlwhite))
 
        Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Host Scheduler" <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Hosts Templates"
        $RDSSchedules = Get-RASRDSSchedule -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)           If($MSWord -or $PDF)
                {           {
                        WriteWordLine 0 0 "Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)"                   WriteWordLine 2 0 "Templates"
                }           }
                If($Text)           If($Text)
                {           {
                        Line 0 "Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)"                   Line 1 "Templates"
                }           }
                If($HTML)           If($HTML)
                {           {
                        WriteHTMLLine 0 0 "Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)"                   WriteHTMLLine 2 0 "Templates"
                }           }
                    
            $RDSTemplates = Get-RASVDITemplate -Siteid $Site.Id -EA 0 | Where-Object {$_.TemplateType -eq "RDSH"}
        }    
        ElseIf($? -and $Null -eq $RDSSchedules)           If(!$?)
 
                Write-Host " <>                 Write-Warning "
                    `n
                No RD Session Host Scheduler retrieved for Site $($Site.Name).`                   Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)`
                " -ForegroundColor White                   "
 
                        WriteWordLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)"
 
                        Line 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)"
 
        Else <>         ElseIf($? -and $Null -eq $RDSTemplates)
 
  -+                 Write-Host "
                    No RD Session Hosts Templates retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
 
                        WriteWordLine 2 0 "Scheduler" <>                         WriteWordLine 0 0 "No RD Session Hosts Templates retrieved for Site $($Site.Name)"
 
                        Line 1 "Scheduler" <>                         Line 0 "No RD Session Hosts Templates retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 2 0 "Scheduler" <>                         WriteHTMLLine 0 0 "No RD Session Hosts Templates retrieved for Site $($Site.Name)"
 
  <>  
                ForEach($RDSSchedule in $RDSSchedules)    
                {    
                        Write-Verbose "$(Get-Date -Format G): `t`t`tOutput RD Session Host Scheduler $($RDSSchedule.Name)"    
                        $Action = $RDSSchedule.Action    
                        If($RDSSChedule.Action -eq "Reboot")    
                        {    
                                If($RDSSchedule.DrainMode)    
                                {    
                                        $Action = "Reboot - Drain Mode"    
                                }           }
                                Else           Else
                                {           {
                                        $Action = "Reboot"    
                                }    
                        }    
     
                        If($Action -eq "Reboot - Drain Mode")    
                        {    
                                Switch ($RDSSchedule.CompleteRebootInSecs)    
                                {    
                                        600             {$TimeDuration = "10 minutes"; Break}    
                                        900             {$TimeDuration = "15 minutes"; Break}    
                                        1800    {$TimeDuration = "30 minutes"; Break}    
                                        2700    {$TimeDuration = "45 minutes"; Break}    
                                        3600    {$TimeDuration = "1 hour"; Break}    
                                        7200    {$TimeDuration = "2 hours"; Break}    
                                        10800   {$TimeDuration = "3 hours"; Break}    
                                        Default {$TimeDuration = "Unable to determine Complete in seconds: $($RDSSchedule.CompleteRebootInSecs)"; Break}    
                                }    
                                    
                                Switch ($RDSSchedule.ForceRebootAfterSecs)    
                                {    
                                        900             {$ForceRebootTime = "15 minutes"; Break}    
                                        1800    {$ForceRebootTime = "30 minutes"; Break}    
                                        2700    {$ForceRebootTime = "45 minutes"; Break}    
                                        3600    {$ForceRebootTime = "1 hour"; Break}    
                                        7200    {$ForceRebootTime = "2 hours"; Break}    
                                        10800   {$ForceRebootTime = "3 hours"; Break}    
                                        21600   {$ForceRebootTime = "6 hours"; Break}    
                                        43200   {$ForceRebootTime = "12 hours"; Break}    
                                        86400   {$ForceRebootTime = "1 day"; Break}    
                                        Default {$ForceRebootTime = "Unable to determine Force reboot after seconds: $($RDSSchedule.ForceRebootAfterSecs)"; Break}    
                                }    
                        }    
                        ElseIf($Action -eq "Disable")    
                        {    
                                Switch ($RDSSchedule.DurationInSecs)    
                                {    
                                        600             {$TimeDuration = "10 minutes"; Break}    
                                        900             {$TimeDuration = "15 minutes"; Break}    
                                        1800    {$TimeDuration = "30 minutes"; Break}    
                                        2700    {$TimeDuration = "45 minutes"; Break}    
                                        3600    {$TimeDuration = "1 hour"; Break}    
                                        7200    {$TimeDuration = "2 hours"; Break}    
                                        10800   {$TimeDuration = "3 hours"; Break}    
                                        21600   {$TimeDuration = "6 hours"; Break}    
                                        43200   {$TimeDuration = "12 hours"; Break}    
                                        86400   {$TimeDuration = "1 day"; Break}    
                                        Default {$TimeDuration = "Unable to determine Duration in seconds: $($RDSSchedule.DurationInSecs)"; Break}    
                                }    
                                    
                                Switch ($RDSSchedule.DisableAction)    
                                {    
                                        "KeepSessionState"                      {$OnDisable = "Keep current sessions state"; Break}    
                                        "DisconnectActiveSessions"      {$OnDisable = "Disconnect any active session"; Break}    
                                        "ResetAllSessions"                      {$OnDisable = "Reset all sessions"; Break}    
                                        Default                                         {$OnDisable = "Unable to determine On disable: $($RDSSchedule.DisableAction)"; Break}    
                                }    
                        }    
                            
                        Switch ($RDSSchedule.Repeat)                   ForEach($RDSTemplate in $RDSTemplates)
                        {                   {
                                Never                   {$Repeat = "Never "; Break}                           $TemplateProvider = Get-RASProvider -Id $RDSTemplate.ProviderId -EA 0 4>$Null
                                EveryDay                {$Repeat = "Every day"; Break}    
                                EveryWeek               {$Repeat = "Every week"; Break}    
                                Every2Weeks             {$Repeat = "Every 2 weeks"; Break}    
                                EveryMonth              {$Repeat = "Every month"; Break}    
                                EveryYear               {$Repeat = "Every year"; Break}    
                                SpecificDays    {$Repeat = "Every $($RDSSchedule.SpecificDays)"; Break}    
                                Default                 {$Repeat = "Unable to determine the Repeat: $($RDSSchedule.Repeat)"; Break}    
                        }    
 
                        $Target = @() <>  
                        If($RDSSchedule.TargetType -eq "Server")    
                        {    
                                ForEach($Item in $RDSSchedule.TargetIds)    
                                {    
                                        $Result = Get-RASRDS -Id $Item -EA 0 4>$Null    
                                            
                                        If($? -and $Null -ne $Result)                           If($? -and $Null -ne $TemplateProvider)
                                        {                           {
                                                $Target += $Result.Server                                   $TemplateProviderName = $TemplateProvider.Server
                                    $TemplateProviderType = GetVDIType $TemplateProvider.Type
                                        }                           }
                                        Else                           Else
                                        {                           {
                                                Target += "Unable to find RDS Server for ID $($Item)"                                   $TemplateProviderName = ""
                                        }                                   $TemplateProviderType = ""
                                }    
 
                        ElseIf($RDSSchedule.TargetType -eq "ServerGroup") <>  
                        {    
                                ForEach($Item in $RDSSchedule.TargetIds)                           $TemplateVM = Get-RASVM -Id $RDSTemplate.VMId -ProviderId $RDSTemplate.ProviderId -EA 0 4>$Null
                                {    
                                        $Result = Get-RASRDSGroup -Id $Item -EA 0 4>$Null    
                                                                  
                                        If($? -and $Null -ne $Result)                           If($? -and $Null -ne $TemplateVM)
                                        {                           {
                                                $Target += $Result.Name    
                                        }                                   <#
                                            Values          Description
                                            Unknown         The VM is in the 'Unknown' state
                                            On                  The VM is powered on.
                                            Off                 The VM is powered off
                                            Paused          The VM is already, or in the process of being, suspended
                                            CloningFailed   Failed to clone the VM.
                                            CloningCanceled VM cloning was cancelled
                                        Else                                   #>
                                    Switch($TemplateVM.State)
                                        {                                   {
                                            "Unknown"                       {$TemplatePowerState = "Unknown"; Break}
                                                Target += "Unable to find RDS Server Group for ID $($Item)"                                           "On"                            {$TemplatePowerState = "Powered on"; Break}
                                        }                                           "Off"                           {$TemplatePowerState = "Powered off"; Break}
                                            "Paused"                        {$TemplatePowerState = "Paused"; Break}
                                            "CloningFailed"         {$TemplatePowerState = "Cloning failed"; Break}
                                            "CloningCanceled"       {$TemplatePowerState = "Cloning canceled"; Break}
                                            Default                         {$TemplatePowerState = "Unable to determine template VM power state: $($TemplateVM.State)"; Break}
 
                                Target += "Unable to determine Target for TargetType: $($RDSSchedule.TargetType)" <>                                 $TemplatePowerState = "Unknown"
 
                                WriteWordLine 3 0 "Schedule Name $($RDSSchedule.Name)" <>                                 WriteWordLine 3 0 "Template Name $($RDSTemplate.Name)"
 
                                $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Name"; Value = $RDSTemplate.Name; }) > $Null
                                $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null                                   #$ScriptInformation.Add(@{Data = "Status"; Value = "Can't find"; }) > $Null
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null                                   $ScriptInformation.Add(@{Data = "Power state"; Value = $TemplatePowerState; }) > $Null
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                   #$ScriptInformation.Add(@{Data = "Agent status"; Value = "Can't find"; }) > $Null
                                        }    
                                }    
                                    
                                $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime; }) > $Null                                   #$ScriptInformation.Add(@{Data = "Distribution"; Value = "Can't find"; }) > $Null
                                $ScriptInformation.Add(@{Data = "Repeat"; Value = $Repeat; }) > $Null                                   $ScriptInformation.Add(@{Data = "Provider"; Value = $TemplateProviderName; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Provider type"; Value = $TemplateProviderType; }) > $Null
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RDSSchedule.AdminLastMod; }) > $Null                                   $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RDSTemplate.AdminLastMod; }) > $Null
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $RDSSchedule.TimeLastMod.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Modified on"; Value = $RDSTemplate.TimeLastMod.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $RDSSchedule.AdminCreate; }) > $Null                                   $ScriptInformation.Add(@{Data = "Created by"; Value = $RDSTemplate.AdminCreate; }) > $Null
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $RDSSchedule.TimeCreate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Created on"; Value = $RDSTemplate.TimeCreate.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "ID"; Value = $RDSSchedule.Id.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "ID"; Value = $RDSTemplate.Id.ToString(); }) > $Null
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 250;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Name`t`t`t: " $RDSSchedule.Name    
                                Line 2 "Action`t`t`t: " $Action    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                Line 2 "Target`t`t`t: " $Item    
                                        }    
                                        Else    
                                        {    
                                                Line 6 "  " $Item    
                                        }    
                                }    
                                    
                                Line 2 "Start`t`t`t: " $RDSSchedule.StartDateTime    
                                Line 2 "Repeat`t`t`t: " $Repeat    
                                Line 2 "Description`t`t: " $RDSSchedule.Description    
                                Line 2 "Last modification by`t: " $RDSSchedule.AdminLastMod    
                                Line 2 "Modified on`t`t: " $RDSSchedule.TimeLastMod.ToString()    
                                Line 2 "Created by`t`t: " $RDSSchedule.AdminCreate    
                                Line 2 "Created on`t`t: " $RDSSchedule.TimeCreate.ToString()    
                                Line 2 "ID`t`t`t: " $RDSSchedule.Id.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 3 0 "Schedule Name $($RDSSchedule.Name)"    
                                $rowdata = @()    
                                $columnHeaders = @("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite)    
                                $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                    
                                $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime,$htmlwhite))    
                                $rowdata += @(,("Repeat",($Script:htmlsb),$Repeat,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb),$RDSSchedule.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb),$RDSSchedule.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb),$RDSSchedule.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb),$RDSSchedule.TimeCreate.ToString(),$htmlwhite))    
                                $rowdata += @(,("ID",($Script:htmlsb),$RDSSchedule.Id.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        #Properties    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "General"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "General"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Enable Schedule"; Value = $RDSSchedule.Enabled.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
 
                                Line 3 "Enable Schedule`t`t`t: " $RDSSchedule.Enabled.ToString() <>  
                                Line 3 "Name`t`t`t`t: " $RDSSchedule.Name                                   Line 2 "Name: " $RDSTemplate.Name
                                Line 3 "Action`t`t`t`t: " $Action                                   #Line 2 "Status`t`t`t: " "Can't find"
                                Line 3 "Description`t`t`t: " $RDSSchedule.Description    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "Target`t`t`t`t: " $Item    
                                        }    
                                        Else    
                                        {    
                                                Line 7 "  " $Item    
                                        }    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Enable schedule",($Script:htmlsb),$RDSSchedule.Enabled.ToString(),$htmlwhite)    
                                $rowdata += @(,("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite))    
                                $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                    
                                $msg = "General"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Trigger    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Trigger"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Trigger"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Date"; Value = $RDSSchedule.StartDateTime.ToShortDateString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime.ToShortTimeString(); }) > $Null    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Complete in"; Value = $TimeDuration  ; }) > $Null    
                                }    
                                ElseIf($Action -eq "Disable")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Duration"; Value = $TimeDuration; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "Repeat"; Value = $Repeat; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Date`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortDateString()    
                                Line 3 "Start`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortTimeString()    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        Line 3 "Complete in`t`t`t: " $TimeDuration                                   Line 2 "Power state`t`t: " $TemplatePowerState
                                }                                   #Line 2 "Agent status`t`t: " "Can't find"
                                ElseIf($Action -eq "Disable")    
                                {    
                                        Line 3 "Duration`t`t`t: " $TimeDuration                                   #Line 2 "Distribution`t`t: " "Can't find"
                                }    
                                Line 3 "Repeat`t`t`t`t: " $Repeat    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Date",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortDateString(),$htmlwhite)    
                                $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortTimeString(),$htmlwhite))    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $rowdata += @(,("Complete in",($Script:htmlsb),$TimeDuration,$htmlwhite))    
                                }    
                                ElseIf($Action -eq "Disable")    
                                {    
                                        $rowdata += @(,("Duration",($Script:htmlsb),$TimeDuration,$htmlwhite))    
                                }    
                                $rowdata += @(,("Repeat",($Script:htmlsb),$Repeat,$htmlwhite))    
     
                                $msg = "Trigger"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Options    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Options"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Options"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Send message before schedule is triggered"; Value = ""; }) > $Null    
     
                                If($RDSSChedule.Messages.Count -gt 0)    
                                {    
                                        ForEach($Item in $RDSSChedule.Messages)    
                                        {    
                                                Switch ($Item.SendMsgSecs)    
                                                {    
                                                        900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}    
                                                        1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}    
                                                        2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}    
                                                        3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}    
                                                        7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}    
                                                        10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}    
                                                        Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}    
                                                }    
                                                    
                                                $ScriptInformation.Add(@{Data = "Enabled"; Value = $Item.Enabled.ToString(); }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Body"; Value = $Item.Message; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Title"; Value = $Item.MessageTitle; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Time"; Value = $MsgTime; }) > $Null    
                                        }    
                                }    
     
                                If($Action -ne "Disable")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Enable Drain Mode"; Value = $RDSSchedule.DrainMode.ToString(); }) > $Null    
                                }    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Force server reboot after"; Value = $ForceRebootTime; }) > $Null    
                                }    
                                If($Action -like "Reboot*")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Enforce schedule for currently inactive RD Session Host"; Value = $RDSSchedule.EnforceOnInactive.ToString(); }) > $Null    
                                }    
                                If($Action -eq "Disable")    
                                {    
                                        $ScriptInformation.Add(@{Data = "On disable"; Value = $OnDisable; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Send message before schedule is triggered"    
                                    
                                If($RDSSChedule.Messages.Count -gt 0)    
                                {    
                                        ForEach($Item in $RDSSChedule.Messages)    
                                        {    
                                                Switch ($Item.SendMsgSecs)    
                                                {    
                                                        900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}    
                                                        1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}    
                                                        2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}    
                                                        3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}    
                                                        7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}    
                                                        10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}    
                                                        Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}    
                                                }    
                                                    
                                                Line 3 "Enabled`t`t`t`t: " $Item.Enabled.ToString()    
                                                Line 3 "Body`t`t`t`t: " $Item.Message    
                                                Line 3 "Title`t`t`t`t: " $Item.MessageTitle    
                                                Line 3 "Time`t`t`t`t: " $MsgTime    
                                        }    
                                }    
     
                                If($Action -ne "Disable")    
                                {    
                                        Line 3 "Enable Drain Mode`t`t: " $RDSSchedule.DrainMode.ToString()    
                                }    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        Line 3 "Force server reboot after`t: " $ForceRebootTime    
                                }    
                                If($Action -like "Reboot*")    
                                {    
                                        Line 3 "Enforce schedule for currently"    
                                        Line 3 "inactive RD Session Host`t: " $RDSSchedule.EnforceOnInactive.ToString()    
                                }    
                                If($Action -eq "Disable")    
                                {    
                                        Line 3 "On disable`t`t`t: " $OnDisable    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Send message before schedule is triggered",($Script:htmlsb),"",$htmlwhite)    
                                    
                                If($RDSSChedule.Messages.Count -gt 0)    
                                {    
                                        ForEach($Item in $RDSSChedule.Messages)    
                                        {    
                                                Switch ($Item.SendMsgSecs)    
                                                {    
                                                        900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}    
                                                        1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}    
                                                        2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}    
                                                        3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}    
                                                        7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}    
                                                        10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}    
                                                        Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}    
                                                }    
                                                    
                                                $rowdata += @(,("Enabled",($Script:htmlsb),$Item.Enabled.ToString(),$htmlwhite))    
                                                $rowdata += @(,("Body",($Script:htmlsb),$Item.Message,$htmlwhite))    
                                                $rowdata += @(,("Title",($Script:htmlsb),$Item.MessageTitle,$htmlwhite))    
                                                $rowdata += @(,("Time",($Script:htmlsb),$MsgTime,$htmlwhite))    
                                        }    
                                }    
     
                                If($Action -ne "Disable")    
                                {    
                                        $rowdata += @(,("Enable Drain Mode",($Script:htmlsb),$RDSSchedule.DrainMode.ToString(),$htmlwhite))    
                                }    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $rowdata += @(,("Force server reboot after",($Script:htmlsb),$ForceRebootTime,$htmlwhite))    
                                }    
                                If($Action -like "Reboot*")    
                                {    
                                        $rowdata += @(,("Enforce schedule for currently inactive RD Session Host",($Script:htmlsb),$RDSSchedule.EnforceOnInactive.ToString(),$htmlwhite))    
                                }    
                                If($Action -eq "Disable")    
                                {    
                                        $rowdata += @(,("On disable",($Script:htmlsb),$OnDisable,$htmlwhite))    
                                }    
     
                                $msg = "Options"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                }    
        }    
     
        $VDIHosts = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve VDI for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve VDI for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $VDIHosts)    
        {    
                Write-Host "    
                No VDI retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No VDI retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No VDI retrieved for Site $($Site.Name)"                                   Line 2 "Provider`t`t: " $TemplateProviderName
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No VDI retrieved for Site $($Site.Name)"    
                }    
        }    
        Else    
        {    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 2 0 "VDI"    
                }    
                If($Text)    
                {    
                        Line 1 "VDI"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 "VDI"    
                }    
     
                Write-Verbose "$(Get-Date -Format G): `t`tOutput VDI"    
                ForEach($VDIHost in $VDIHosts)    
                {    
                        $VDIHostStatus = Get-RASProviderStatus -Id $VDIHost.Id -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                Write-Warning "    
                                `n    
                                Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)`    
                                "    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"    
                                }    
                        }    
                        ElseIf($? -and $Null -eq $VDIHostStatus)    
                        {    
                                Write-Host "    
                                No VDI Host Status retrieved for VDI Host $($VDIHost.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"    
                                }    
                        }    
                        Else    
                        {    
                                $FullProviderStatus = GetRASStatus $VDIHostStatus.AgentState    
     
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 3 0 "Providers"    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Providers"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 3 0 "Providers"    
                                }    
     
                                $VDIType = GetVDIType $VDIHost.Type    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Provider"; Value = $VDIHost.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VDI Agent"; Value = $VDIHost.VDIAgent; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $FullProviderStatus; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Direct address"; Value = $VDIHost.DirectAddress; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $VDIHost.Description; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Log level"; Value = $VDIHostStatus.LogLevel; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $VDIHost.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $VDIHost.TimeLastMod.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $VDIHost.AdminCreate; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $VDIHost.TimeCreate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $VDIHost.Id.ToString(); }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Provider`t`t: " $VDIHost.Server                                   Line 2 "Provider type`t`t: " $TemplateProviderType
                                        Line 3 "Type`t`t`t: " $VDIType    
                                        Line 3 "VDI Agent`t`t: " $VDIHost.VDIAgent    
                                        Line 3 "Status`t`t`t: " $FullProviderStatus    
                                        Line 3 "Direct address`t`t: " $VDIHost.DirectAddress    
                                        Line 3 "Description`t`t: " $VDIHost.Description    
                                        Line 3 "Log level`t`t: " $VDIHostStatus.LogLevel    
                                        Line 3 "Last modification by`t: " $VDIHost.AdminLastMod                                   Line 2 "Last modification by`t: " $RDSTemplate.AdminLastMod
                                        Line 3 "Modified on`t`t: " $VDIHost.TimeLastMod.ToString()                                   Line 2 "Modified on`t`t: " $RDSTemplate.TimeLastMod.ToString()
                                        Line 3 "Created by`t`t: " $VDIHost.AdminCreate                                   Line 2 "Created by`t`t: " $RDSTemplate.AdminCreate
                                        Line 3 "Created on`t`t: " $VDIHost.TimeCreate.ToString()                                   Line 2 "Created on`t`t: " $RDSTemplate.TimeCreate.ToString()
                                        Line 3 "ID`t`t`t: " $VDIHost.Id.ToString()                                   Line 2 "ID`t`t`t: " $RDSTemplate.Id.ToString()
                                        Line 0 ""                                   Line 0 ""
                                }                           }
                                If($HTML)                           If($HTML)
                                {                           {
                                        $rowdata = @()                                   $rowdata = @()
                                        $columnHeaders = @("Provider",($Script:htmlsb),$VDIHost.Server,$htmlwhite)                                   $columnHeaders = @("Name",($Script:htmlsb),$RDSTemplate.Name,$htmlwhite)
                                        $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))                                   #$rowdata += @(,("Status",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $rowdata += @(,("VDI Agent",($Script:htmlsb),$VDIHost.VDIAgent,$htmlwhite))                                   $rowdata += @(,("Power state",($Script:htmlsb),$TemplatePowerState,$htmlwhite))
                                        $rowdata += @(,("Status",($Script:htmlsb),$FullProviderStatus,$htmlwhite))                                   #$rowdata += @(,("Agent status",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $rowdata += @(,("Direct address",($Script:htmlsb),$VDIHost.DirectAddress,$htmlwhite))                                   #$rowdata += @(,("Distribution",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $rowdata += @(,("Description",($Script:htmlsb),$VDIHost.Description,$htmlwhite))                                   $rowdata += @(,("Provider",($Script:htmlsb),$TemplateProviderName,$htmlwhite))
                                        $rowdata += @(,("Log level",($Script:htmlsb),$VDIHostStatus.LogLevel,$htmlwhite))                                   $rowdata += @(,("Provider type",($Script:htmlsb),$TemplateProviderType,$htmlwhite))
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $VDIHost.AdminLastMod,$htmlwhite))                                   $rowdata += @(,("Last modification by",($Script:htmlsb), $RDSTemplate.AdminLastMod,$htmlwhite))
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $VDIHost.TimeLastMod.ToString(),$htmlwhite))                                   $rowdata += @(,("Modified on",($Script:htmlsb), $RDSTemplate.TimeLastMod.ToString(),$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $VDIHost.AdminCreate,$htmlwhite))                                   $rowdata += @(,("Created by",($Script:htmlsb), $RDSTemplate.AdminCreate,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $VDIHost.TimeCreate.ToString(),$htmlwhite))                                   $rowdata += @(,("Created on",($Script:htmlsb), $RDSTemplate.TimeCreate.ToString(),$htmlwhite))
                                        $rowdata += @(,("Id",($Script:htmlsb),$VDIHost.Id.ToString(),$htmlwhite))                                   $rowdata += @(,("Id",($Script:htmlsb),$RDSTemplate.Id.ToString(),$htmlwhite))
 
                                        $msg = "" <>                                 $msg = ""
                                        $columnWidths = @("200","275")                                   $columnWidths = @("200","275")
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                }    
 
                                Line 3 "General" <>                                 Line 2 "General"
 
                        $HostPA = Get-RASPA -Id $VDIHost.PreferredPAId -EA 0 4>$Null <>                         Switch($RDSTemplate.UnusedVMDurationMins)
                            
                        If($? -and -$Null -ne $HostPA)    
 
                                If($VDIHost.VDIAgent -eq $HostPa.Server) <>                                 0               {$DeleteVMTime = "Never"; Break}
                                {    
                                        $DedicatedVDIAgent = $False    
                                }    
                                Else    
                                {    
                                        $DedicatedVDIAgent = $True                                   5               {$DeleteVMTime = "5 minutes"; Break}
                                    30              {$DeleteVMTime = "30 minutes"; Break}
                                    60              {$DeleteVMTime = "1 hour"; Break}
                                    1440    {$DeleteVMTime = "1 day"; Break}
                                    10080   {$DeleteVMTime = "1 week"; Break}
                                    43200   {$DeleteVMTime = "30 days"; Break}
                                    Default {$DeleteVMTime = "Unable to determine Delete unused guest VMs after: $($RDSTemplate.UnusedVMDurationMins)"; Break}
                                }                           }
                        }                          
                        ElseIf($? -and $Null -eq $HostPA)                           Switch($RDSTemplate.CloneMethod)
 
                                $DedicatedVDIAgent = $False <>                                 "LinkedClone"   {$CloneMethod = "Create a linked clone"; Break}
                                    "FullClone"             {$CloneMethod = "Create a full clone"; Break}
                                    Default                 {$CloneMethod = "Unable to determine Clone method: $($RDSTemplate.CloneMethod)"; Break}
 
                        Else <>  
                        {    
                                $DedicatedVDIAgent = $False    
                        }    
                            
 
                                $ScriptInformation.Add(@{Data = "Enable provider in site"; Value = $VDIHost.Enabled.ToString(); }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null                                   $ScriptInformation.Add(@{Data = "Template name"; Value = $RDSTemplate.Name; }) > $Null
                                If($VDIType -eq "Azure")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $VDIHost.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "Maximum guest VMs"; Value = $RDSTemplate.MaxVMs.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $VDIHost.Description; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Subscription details"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Keep available buffer"; Value = $RDSTemplate.PreCreatedVMs.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Authentication URL"; Value = $VDIHost.AzureInfo.AuthenticationURL; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Management URL"; Value = $VDIHost.AzureInfo.ManagementURL; }) > $Null                                   $ScriptInformation.Add(@{Data = "Guest VM name"; Value = $RDSTemplate.VMNameFormat; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Resource URI"; Value = $VDIHost.AzureInfo.ResourceURI; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Tenant ID"; Value = $VDIHost.AzureInfo.TenantID; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Subscription ID"; Value = $VDIHost.AzureInfo.SubscriptionID; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Host"; Value = $VDIHost.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Port"; Value = $VDIHost.VDIPort.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $VDIHost.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Guest VM state after the preparation"; Value = "Can't find"; }) > $Null
                                }    
                                $ScriptInformation.Add(@{Data = "Dedicated VDI Agent"; Value = $DedicatedVDIAgent.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Delete unused guest VMs after"; Value = $DeleteVMTime; }) > $Null
                                If($DedicatedVDIAgent)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Agent address"; Value = $VDIHost.VDIAgent; }) > $Null                                   $ScriptInformation.Add(@{Data = "Clone method"; Value = $CloneMethod; }) > $Null
                                }    
 
                                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 250;
 
  <>                                 Line 3 "Template name`t`t`t`t`t: " $RDSTemplate.Name
                                    Line 3 "Maximum guest VMs`t`t`t`t: " $RDSTemplate.MaxVMs.ToString()
                                Line 4 "Enable provider in site`t`t: " $VDIHost.Enabled.ToString()                                   Line 3 "Keep available buffer`t`t`t`t: " $RDSTemplate.PreCreatedVMs.ToString()
                                Line 4 "Type`t`t`t`t: " $VDIType    
                                If($VDIType -eq "Azure")    
                                {    
                                        Line 4 "Name`t`t`t`t: " $VDIHost.Server                                   Line 3 "Guest VM name`t`t`t`t`t: " $RDSTemplate.VMNameFormat
                                        Line 4 "Description`t`t`t: " $VDIHost.Description                                   Line 3 "Guest VM state after the preparation`t: " "Can't find"
                                        Line 4 "Subscription details`t`t: "     
                                        Line 5 "Authentication URL: " $VDIHost.AzureInfo.AuthenticationURL    
                                        Line 5 "Management URL`t  : " $VDIHost.AzureInfo.ManagementURL    
                                        Line 5 "Resource URI`t  : " $VDIHost.AzureInfo.ResourceURI    
                                        Line 4 "Tenant ID`t`t`t: " $VDIHost.AzureInfo.TenantID    
                                        Line 4 "Subscription ID`t`t`t: " $VDIHost.AzureInfo.SubscriptionID    
                                }    
                                Else    
                                {    
                                        Line 4 "Host`t`t`t`t: " $VDIHost.Server    
                                        Line 4 "Port`t`t`t`t: " $VDIHost.VDIPort.ToString()    
                                        Line 4 "Description`t`t`t: " $VDIHost.Description    
                                }    
                                Line 4 "Dedicated VDI Agent`t`t: " $DedicatedVDIAgent.ToString()    
                                If($DedicatedVDIAgent)    
                                {    
                                        Line 4 "Agent address`t`t`t: " $VDIHost.VDIAgent                                   Line 3 "Delete unused guest VMs after`t`t`t: " $DeleteVMTime
                                }                                   Line 3 "Clone method`t`t`t`t`t: " $CloneMethod
 
                                $columnHeaders = @("Enable provider in site",($Script:htmlsb),$VDIHost.Enabled.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Template name",($Script:htmlsb),$RDSTemplate.Name,$htmlwhite)
                                $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))    
                                If($VDIType -eq "Azure")    
                                {    
                                        $rowdata += @(,( "Name",($Script:htmlsb), $VDIHost.Server,$htmlwhite))                                   $rowdata += @(,("Maximum guest VMs",($Script:htmlsb),$RDSTemplate.MaxVMs.ToString(),$htmlwhite))
                                        $rowdata += @(,( "Description",($Script:htmlsb), $VDIHost.Description,$htmlwhite))    
                                        $rowdata += @(,( "Subscription details",($Script:htmlsb), "",$htmlwhite))                                   $rowdata += @(,("Keep available buffer",($Script:htmlsb),$RDSTemplate.PreCreatedVMs.ToString(),$htmlwhite))
                                        $rowdata += @(,( "     Authentication URL",($Script:htmlsb), $VDIHost.AzureInfo.AuthenticationURL,$htmlwhite))    
                                        $rowdata += @(,( "     Management URL",($Script:htmlsb), $VDIHost.AzureInfo.ManagementURL,$htmlwhite))                                   $rowdata += @(,("Guest VM name",($Script:htmlsb),$RDSTemplate.VMNameFormat,$htmlwhite))
                                        $rowdata += @(,( "     Resource URI",($Script:htmlsb), $VDIHost.AzureInfo.ResourceURI,$htmlwhite))    
                                        $rowdata += @(,( "Tenant ID",($Script:htmlsb), $VDIHost.AzureInfo.TenantID,$htmlwhite))    
                                        $rowdata += @(,( "Subscription ID",($Script:htmlsb), $VDIHost.AzureInfo.SubscriptionID,$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Host",($Script:htmlsb),$VDIHost.Server,$htmlwhite))    
                                        $rowdata += @(,("Port",($Script:htmlsb),$VDIHost.VDIPort.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Description",($Script:htmlsb),$VDIHost.Description,$htmlwhite))                                   $rowdata += @(,("Guest VM state after the preparation",($Script:htmlsb),"Can't find",$htmlwhite))
                                }    
                                $rowdata += @(,("Dedicated VDI Agent",($Script:htmlsb),$DedicatedVDIAgent.ToString(),$htmlwhite))                                   $rowdata += @(,("Delete unused guest VMs after",($Script:htmlsb),$DeleteVMTime,$htmlwhite))
                                If($DedicatedVDIAgent)    
                                {    
                                        $rowdata += @(,("Agent address",($Script:htmlsb),$VDIHost.VDIAgent,$htmlwhite))                                   $rowdata += @(,("Clone method",($Script:htmlsb),$CloneMethod,$htmlwhite))
                                }    
 
                                $columnWidths = @("200","275") <>                                 $columnWidths = @("300","275")
 
                        #Credentials <>                         #Advanced
 
                                WriteWordLine 4 0 "Credentials" <>                                 WriteWordLine 4 0 "Advanced"
 
                                Line 3 "Credentials" <>                                 Line 2 "Advanced"
 
                                If($VDIType -eq "Azure") <>                                 $ScriptInformation.Add(@{Data = "Folder"; Value = $RDSTemplate.FolderName; }) > $Null
                                {                                   $ScriptInformation.Add(@{Data = "Resource pool"; Value = $RDSTemplate.NativePoolName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Application ID"; Value = $VDIHost.VDIUsername; }) > $Null                                   $ScriptInformation.Add(@{Data = "Physical Host"; Value = $RDSTemplate.PhysicalHostName; }) > $Null
                                }                                   $ScriptInformation.Add(@{Data = "Enable hardware acceleration graphics licensing support"; Value = $RDSTemplate.HWGPU.ToString(); }) > $Null
                                Else                                   #$ScriptInformation.Add(@{Data = "Use a separate network interface for LAN access"; Value = "Can't find"; }) > $Null
                                {                                   #$ScriptInformation.Add(@{Data = "Specify management network details"; Value = ""; }) > $Null
                                    #$ScriptInformation.Add(@{Data = "     Address"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Username"; Value = $VDIHost.VDIUsername; }) > $Null                                   #$ScriptInformation.Add(@{Data = "     Subnet mask"; Value = ""; }) > $Null
                                }    
 
                                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 250;
 
                                If($VDIType -eq "Azure") <>                                 Line 3 "Folder`t`t`t`t: " $RDSTemplate.FolderName
                                {                                   Line 3 "Resource pool`t`t`t: " $RDSTemplate.NativePoolName
                                    Line 3 "Physical Host`t`t`t: " $RDSTemplate.PhysicalHostName
                                    Line 3 "Enable hardware acceleration "
                                        Line 4 "Application ID: " $VDIHost.VDIUsername                                   Line 3 "graphics licensing support`t: " $RDSTemplate.HWGPU.ToString()
                                }                                   #Line 3 "Use a separate network interface for LAN access: " "Can't find"
                                Else                                   #Line 3 "Specify management network details:"
                                {    
                                        Line 4 "Username`t`t`t: " $VDIHost.VDIUsername                                   #Line 4 "Address`t`t`t: " $DeleteVMTime
                                }                                   #Line 4 "Subnet mask`t`t: " $CloneMethod
 
                                If($VDIType -eq "Azure") <>  
                                {    
                                        $columnHeaders = @("Application ID",($Script:htmlsb),$VDIHost.VDIUsername,$htmlwhite)                                   $columnHeaders = @("Folder",($Script:htmlsb),$RDSTemplate.FolderName,$htmlwhite)
                                }                                   $rowdata += @(,("Resource pool",($Script:htmlsb),$RDSTemplate.NativePoolName,$htmlwhite))
                                Else                                   $rowdata += @(,("Physical Host",($Script:htmlsb),$RDSTemplate.PhysicalHostName,$htmlwhite))
                                {                                   $rowdata += @(,("Enable hardware acceleration graphics licensing support",($Script:htmlsb),$RDSTemplate.HWGPU.ToString(),$htmlwhite))
                                    #$rowdata += @(,("Use a separate network interface for LAN access",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $columnHeaders = @("Username",($Script:htmlsb),$VDIHost.VDIUsername,$htmlwhite)                                   #$rowdata += @(,("Specify management network details",($Script:htmlsb),"",$htmlwhite))
                                }                                   #$rowdata += @(,("     Address",($Script:htmlsb),"",$htmlwhite))
                                    #$rowdata += @(,("     Subnet mask",($Script:htmlsb),"",$htmlwhite))
 
                                $msg = "Credentials" <>                                 $msg = "Advanced"
                                $columnWidths = @("200","275")                                   $columnWidths = @("300","275")
 
  <>                         
                        #Agent Settings                           #Preparation
 
                                WriteWordLine 4 0 "Agent settings" <>                                 WriteWordLine 4 0 "Preparation"
 
                                Line 3 "Agent settings" <>                                 Line 2 "Preparation"
 
                        <#Switch ($VDIHost.DragAndDropMode) +-  
                        {    
                                "Bidirectional"         {$VDIHostDragAndDrop = "Bidirectional"; Break}    
                                "Disabled"                      {$VDIHostDragAndDrop = "Disabled"; Break}    
                                "ClientToServer"        {$VDIHostDragAndDrop = "Client to server only"; Break}    
                                "ServerToClient"        {$VDIHostDragAndDrop = "Server to client only"; Break}    
                                Default                         {$VDIHostDragAndDrop = "Unable to determine Drag and drop: $($VDIHost.DragAndDropMode)"; Break}    
                        }#>    
     
                        Switch ($VDIHost.FileTransferMode)    
                        {    
                                "Bidirectional"         {$VDIHostFileTransferMode = "Bidirectional"; Break}    
                                "Disabled"                      {$VDIHostFileTransferMode = "Disabled"; Break}    
                                "ClientToServer"        {$VDIHostFileTransferMode = "Client to server only"; Break}    
                                "ServerToClient"        {$VDIHostFileTransferMode = "Server to client only"; Break}    
                                Default                         {$VDIHostFileTransferMode = "Unable to determine File Transfer mode: $($VDIHost.FileTransferMode)"; Break}    
                        }    
     
                        If($VDIHost.FileTransferLocation -eq "")    
                        {    
                                $VDIHostFileTransferLocation = "Default download location"    
                        }    
                        Else    
                        {    
                                $VDIHostFileTransferLocation = $VDIHostHost.FileTransferLocation    
                        }    
     
 
                                $ScriptInformation.Add(@{Data = "Allow Client URL/Mail Redirection"; Value = $VDIHost.AllowURLAndMailRedirection.ToString(); }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Support Windows Shell URL namespace objects"; Value = $VDIHost.SupportShellURLNamespaceObjects.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Image preparation tool"; Value = $RDSTemplate.ImagePrepTool.ToString(); }) > $Null
                                #$ScriptInformation.Add(@{Data = "Drag and drop"; Value = $VDIHostDragAndDrop; }) > $Null                                   $ScriptInformation.Add(@{Data = "Computer name"; Value = $RDSTemplate.ComputerName; }) > $Null
                                $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $VDIHostStatus.PreferredPA; }) > $Null                                   $ScriptInformation.Add(@{Data = "Owner name"; Value = $RDSTemplate.OwnerName; }) > $Null
                                $ScriptInformation.Add(@{Data = "Allow file transfer command (HTML5 and Chrome clients)"; Value = $VDIHost.AllowFileTransfer.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Organization"; Value = $RDSTemplate.Organization; }) > $Null
                                $ScriptInformation.Add(@{Data = "Configure File Transfer"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Active Directory domain"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Direction"; Value = $VDIHostFileTransferMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Domain"; Value = $RDSTemplate.Domain; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Location"; Value = $VDIHostFileTransferLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Administrator"; Value = $RDSTemplate.Administrator; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Do not allow to change location"; Value = $VDIHost.FileTransferLockLocation.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "     Target OU"; Value = $RDSTemplate.DomainOrgUnit; }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable drive redirection cache"; Value = $VDIHost.EnableDriveRedirectionCache.ToString(); }) > $Null    
 
                                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 250;
 
                                Line 4 "Allow Client URL/Mail Redirection`t`t`t: " $VDIHost.AllowURLAndMailRedirection.ToString() <>  
                                Line 4 "Support Windows Shell URL namespace objects`t`t: " $VDIHost.SupportShellURLNamespaceObjects.ToString()                                   Line 3 "Image preparation tool`t: " $RDSTemplate.ImagePrepTool.ToString()
                                #Line 4 "Drag and drop`t`t`t`t`t`t: " $VDIHostDragAndDrop                                   Line 3 "Computer name`t`t: " $RDSTemplate.ComputerName
                                Line 4 "Preferred Publishing Agent`t`t`t`t: " $VDIHostStatus.PreferredPA                                   Line 3 "Owner name`t`t: " $RDSTemplate.OwnerName
                                Line 4 "Allow file transfer command (HTML5 and Chrome clients)`t: " $VDIHost.AllowFileTransfer.ToString()                                   Line 3 "Organization`t`t: " $RDSTemplate.Organization
                                Line 4 "Configure File Transfer"                                   Line 3 "Active Directory domain"
                                Line 5 "Direction`t`t`t: " $VDIHostFileTransferMode                                   Line 4 "Domain`t`t: " $RDSTemplate.Domain
                                Line 5 "Location`t`t`t: " $VDIHostFileTransferLocation                                   Line 4 "Administrator`t: " $RDSTemplate.Administrator
                                Line 5 "Do not allow to change location`t: " $VDIHost.FileTransferLockLocation.ToString()                                   Line 4 "Target OU`t: " $RDSTemplate.DomainOrgUnit
                                Line 4 "Enable drive redirection cache`t`t`t`t: " $VDIHost.EnableDriveRedirectionCache.ToString()    
 
                                $columnHeaders = @("Allow Client URL/Mail Redirection",($Script:htmlsb),$VDIHost.AllowURLAndMailRedirection.ToString(),$htmlwhite) <>  
                                $rowdata += @(,("Support Windows Shell URL namespace objects",($Script:htmlsb),$VDIHost.SupportShellURLNamespaceObjects.ToString(),$htmlwhite))                                   $columnHeaders = @("Image preparation tool",($Script:htmlsb),$RDSTemplate.ImagePrepTool.ToString(),$htmlwhite)
                                #$rowdata += @(,("Drag and drop",($Script:htmlsb),$VDIHostDragAndDrop,$htmlwhite))                                   $rowdata += @(,("Computer name",($Script:htmlsb),$RDSTemplate.ComputerName,$htmlwhite))
                                $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$VDIHostStatus.PreferredPA,$htmlwhite))                                   $rowdata += @(,("Owner name",($Script:htmlsb),$RDSTemplate.OwnerName,$htmlwhite))
                                $rowdata += @(,("Allow file transfer command (HTML5 and Chrome clients)",($Script:htmlsb),$VDIHost.AllowFileTransfer.ToString(),$htmlwhite))                                   $rowdata += @(,("Organization",($Script:htmlsb),$RDSTemplate.Organization,$htmlwhite))
                                $rowdata += @(,("Configure File Transfer",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Active Directory domain",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("     Direction",($Script:htmlsb),$VDIHostFileTransferMode,$htmlwhite))                                   $rowdata += @(,("     Domain",($Script:htmlsb),$RDSTemplate.Domain,$htmlwhite))
                                $rowdata += @(,("     Location",($Script:htmlsb),$VDIHostFileTransferLocation,$htmlwhite))                                   $rowdata += @(,("     Administrator",($Script:htmlsb),$RDSTemplate.Administrator,$htmlwhite))
                                $rowdata += @(,("     Do not allow to change location",($Script:htmlsb),$VDIHost.FileTransferLockLocation.ToString(),$htmlwhite))                                   $rowdata += @(,("     Target OU",($Script:htmlsb),$RDSTemplate.DomainOrgUnit,$htmlwhite))
                                $rowdata += @(,("Enable drive redirection cache",($Script:htmlsb),$VDIHost.EnableDriveRedirectionCache.ToString(),$htmlwhite))    
 
                                $msg = "Agent settings" <>                                 $msg = "Preparation"
                                $columnWidths = @("200","275")                                   $columnWidths = @("300","275")
 
  <>                         
                        #RDP Printer                           #Optimization
 
                                WriteWordLine 4 0 "RDP printer" <>                                 WriteWordLine 4 0 "Optimization"
 
                                Line 3 "RDP printer" <>                                 Line 2 "Optimization"
 
                         <>  
                        Switch ($VDIHost.PrinterNameFormat)                           If($RDSTemplate.InheritDefaultOptimizationSettings)
 
                                "PrnFormat_PRN_CMP_SES" {$VDIPrinterNameFormat = "Printername (from Computername) in Session no."; Break} <>                                 #do we inherit site defaults?
                                "PrnFormat_SES_CMP_PRN" {$VDIPrinterNameFormat = "Session no. (Computername from) Printername"; Break}                                   #http://woshub.com/hot-to-convert-sid-to-username-and-vice-versa/
                                "PrnFormat_PRN_REDSES"  {$VDIPrinterNameFormat = "Printername (redirected Session no.)"; Break}                                   #for translating the User SID to the AD user name
                                Default                                 {$VDIPrinterNameFormat = "Unable to determine RDP Printer Name Format: $($VDIHost.PrinterNameFormat)"; Break}                                   #yes we do, get the default settings for the Site
                        }                                   #use the Site default settings
                                    $RDSDefaults = Get-RASRDSDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                                          
                        $VDIRemoveSessionNumberFromPrinter = $VDIHost.RemoveSessionNumberFromPrinterName.ToString()                                   If($? -and $Null -ne $RDSDefaults)
     
                        If($MSWord -or $PDF)    
                        {                                   {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $OPTEnableOptimization            = $RDSDefaults.Optimization.EnableOptimization.ToString()
                                $ScriptInformation.Add(@{Data = "RDP Printer Name Format"; Value = $VDIPrinterNameFormat; }) > $Null                                           $OPTOptimizationType              = $RDSDefaults.Optimization.OptimizationType.ToString()
                                            $OPTWindowsDefenderATPEnabled     = $RDSDefaults.Optimization.WindowsDefenderATPEnabled.ToString()    
                                $ScriptInformation.Add(@{Data = "Remove session number from printer name"; Value = $VDIRemoveSessionNumberFromPrinter; }) > $Null                                           $OPTWindowsComponentsEnabled      = $RDSDefaults.Optimization.WindowsComponentsEnabled.ToString()
                                            $OPTWindowsServicesEnabled        = $RDSDefaults.Optimization.WindowsServicesEnabled.ToString()
                                $Table = AddWordTable -Hashtable $ScriptInformation `                                           $OPTWinodwsScheduledTasksEnabled  = $RDSDefaults.Optimization.WindowsScheduledTasksEnabled.ToString()
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           $OPTWindowsAdvancedOptionsEnabled = $RDSDefaults.Optimization.WindowsAdvancedOptionsEnabled.ToString()
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 4 "RDP Printer Name Format`t`t`t`t: " $VDIPrinterNameFormat    
                                Line 4 "Remove session number from printer name`t`t: " $VDIRemoveSessionNumberFromPrinter    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("RDP Printer Name Format",($Script:htmlsb),$VDIPrinterNameFormat,$htmlwhite)                                           $OPTNetworkPerformanceEnabled     = $RDSDefaults.Optimization.NetworkPerformanceEnabled.ToString()
                                $rowdata += @(,("Remove session number from printer name",($Script:htmlsb),$VDIRemoveSessionNumberFromPrinter,$htmlwhite))    
     
                                $msg = "RDP printer"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                }    
                    
                #Pools    
                    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 3 0 "Pools"    
                }    
                If($Text)    
                {    
                        Line 2 "Pools"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 3 0 "Pools"    
                }    
                    
                If($MSWord -or $PDF)    
                {    
                        $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null    
                        If($? -and $Null -ne $VDIPools)    
                        {    
                                ForEach($VDIPool in $VDIPools)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                           $OPTRegistryEnabled               = $RDSDefaults.Optimization.RegistryEnabled.ToString()
                                        $ScriptInformation.Add(@{Data = "Pools"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "  Name"; Value = $VDIPool.Name; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "  Last modification by"; Value = $VDIPool.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "  Modified on"; Value = $VDIPool.TimeLastMod.ToString(); }) > $Null                                           $OPTVisualEffectsEnabled          = $RDSDefaults.Optimization.VisualEffectsEnabled.ToString()
                                        $ScriptInformation.Add(@{Data = "  Created by"; Value = $VDIPool.AdminCreate; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "  Created on"; Value = $VDIPool.TimeCreate.ToString(); }) > $Null                                           $OPTDiskCleanupEnabled            = $RDSDefaults.Optimization.DiskCleanupEnabled.ToString()
                                            
                                        ForEach($Item in $VDIPool.Members)    
                                        {    
                                                $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null    
                                                    
                                                If($? -and $Null -ne $VDIPoolMembers)    
                                                {    
                                                        $cnt = -1    
                                                        ForEach($VDIPoolMember in $VDIPoolMembers)    
                                                        {    
                                                                Switch($VDIPoolMember.Type)    
                                                                {    
                                                                        "ALLGUESTINHOST"                {$MemberType = "All Guest VMs in Host"; Break}    
                                                                        "ALLGUESTSONPROVIDER"   {$MemberType = "All Guest VMs on Provider"; Break}    
                                                                        "GUEST"                                 {$MemberType = "Guest VM"; Break}    
                                                                        "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}    
                                                                        "TEMPLATEGUEST"                 {$MemberType = "Template"; Break}    
                                                                        "UNKNOWN"                               {$MemberType = "Unknown"; Break}    
                                                                        Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}    
                                                                }    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "    Members"; Value = "Name: $($VDIPoolMember.Name) Type: $MemberType"; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "Name: $($VDIPoolMember.Name) Type: $MemberType"; }) > $Null    
                                                                }    
                                                        }    
                                                }    
                                                ElseIf($? -and $Null -eq $VDIPoolMembers)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "    Members"; Value = "None found"; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "    Members"; Value = "Unable to retrieve"; }) > $Null    
                                                }    
                                        }    
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           $OPTCustomScriptEnabled           = $RDSDefaults.Optimization.CustomScriptEnabled.ToString()
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
 
                        } <>  
                        ElseIf($? -and $Null -eq $VDIPools)    
                        {    
                                WriteWordLine 0 0 "No VDI Pools found for Site $($Site.Name)"    
                        }    
                        Else                                   Else
                        {    
                                WriteWordLine 0 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"    
                        }    
                        WriteWordLine 0 0 ""    
                }    
                If($Text)    
                {    
                        $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null    
                        If($? -and $Null -ne $VDIPools)    
                        {    
                                ForEach($VDIPool in $VDIPools)    
 
                                        Line 3 "Pools" <>                                         #unable to retrieve default, use built-in default values
                                        Line 4 "Name`t`t: " $VDIPool.Name                                           $OPTEnableOptimization            = "False"
                                        Line 4 "Last modification by`t: " $VDIPool.AdminLastMod                                           $OPTOptimizationType              = ""
                                        Line 4 "Modified on`t`t: " $VDIPool.TimeLastMod.ToString()                                           $OPTWindowsDefenderATPEnabled     = "False"
                                        Line 4 "Created by`t`t: " $VDIPool.AdminCreate                                           $OPTWindowsComponentsEnabled      = "False"
                                        Line 4 "Created on`t`t: " $VDIPool.TimeCreate.ToString()                                           $OPTWindowsServicesEnabled        = "False"
                                                                                  $OPTWinodwsScheduledTasksEnabled  = "False"
                                        ForEach($Item in $VDIPool.Members)                                           $OPTWindowsAdvancedOptionsEnabled = "False"
                                        {    
                                                $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null    
                                                    
                                                If($? -and $Null -ne $VDIPoolMembers)    
                                                {    
                                                        $cnt = -1    
                                                        ForEach($VDIPoolMember in $VDIPoolMembers)    
                                                        {    
                                                                Switch($VDIPoolMember.Type)    
                                                                {    
                                                                        "ALLGUESTINHOST"                {$MemberType = "All Guest VMs in Host"; Break}    
                                                                        "ALLGUESTSONPROVIDER"   {$MemberType = "All Guest VMs on Provider"; Break}    
                                                                        "GUEST"                                 {$MemberType = "Guest VM"; Break}    
                                                                        "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}                                           $OPTNetworkPerformanceEnabled     = "False"
                                                                        "TEMPLATEGUEST"                 {$MemberType = "Template"; Break}    
                                                                        "UNKNOWN"                               {$MemberType = "Unknown"; Break}    
                                                                        Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}    
                                                                }    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        Line 4 "Members`t`t: " "Name: $($VDIPoolMember.Name) Type: $MemberType"    
                                                                }    
                                                                Else    
                                                                {    
                                                                        Line 6 "Name: $($VDIPoolMember.Name) Type: $MemberType"    
                                                                }    
                                                        }    
                                                }    
                                                ElseIf($? -and $Null -eq $VDIPoolMembers)    
                                                {    
                                                        Line 4 "Members`t`t: " "None found"    
                                                }    
                                                Else    
                                                {    
                                                        Line 4 "Members`t`t: " "Unable to retrieve"    
                                                }    
                                        }    
                                }    
                                Line 0 ""    
                        }    
                        ElseIf($? -and $Null -eq $VDIPools)    
                        {    
                                Line 0 "No VDI Pools found for Site $($Site.Name)"    
                        }    
                        Else    
                        {    
                                Line 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"    
                        }    
                        Line 0 ""    
                }    
                If($HTML)    
                {    
                        $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null    
                        If($? -and $Null -ne $VDIPools)    
                        {    
                                ForEach($VDIPool in $VDIPools)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Pools",($Script:htmlsb),"",$htmlwhite)    
                                        $rowdata += @(,("  Name",($Script:htmlsb),$VDIPool.Name,$htmlwhite))    
                                        $rowdata += @(,("  Last modification by",($Script:htmlsb), $VDIPool.AdminLastMod,$htmlwhite))    
                                        $rowdata += @(,("  Modified on",($Script:htmlsb), $VDIPool.TimeLastMod.ToString(),$htmlwhite))    
                                        $rowdata += @(,("  Created by",($Script:htmlsb), $VDIPool.AdminCreate,$htmlwhite))    
                                        $rowdata += @(,("  Created on",($Script:htmlsb), $VDIPool.TimeCreate.ToString(),$htmlwhite))    
                                            
                                        ForEach($Item in $VDIPool.Members)    
                                        {    
                                                $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null    
                                                    
                                                If($? -and $Null -ne $VDIPoolMembers)    
                                                {    
                                                        $cnt = -1    
                                                        ForEach($VDIPoolMember in $VDIPoolMembers)    
                                                        {    
                                                                Switch($VDIPoolMember.Type)    
                                                                {    
                                                                        "ALLGUESTINHOST"                {$MemberType = "All Guest VMs in Host"; Break}    
                                                                        "ALLGUESTSONPROVIDER"   {$MemberType = "All Guest VMs on Provider"; Break}    
                                                                        "GUEST"                                 {$MemberType = "Guest VM"; Break}    
                                                                        "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}    
                                                                        "TEMPLATEGUEST"                 {$MemberType = "Template"; Break}    
                                                                        "UNKNOWN"                               {$MemberType = "Unknown"; Break}    
                                                                        Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}    
                                                                }    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $rowdata += @(,("    Members",($Script:htmlsb),"Name: $($VDIPoolMember.Name) Type: $MemberType",$htmlwhite))    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $rowdata += @(,("",($Script:htmlsb),"Name: $($VDIPoolMember.Name) Type: $MemberType",$htmlwhite))    
                                                                }    
                                                        }    
                                                }    
                                                ElseIf($? -and $Null -eq $VDIPoolMembers)    
                                                {    
                                                        $rowdata += @(,("    Members",($Script:htmlsb),"None found",$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("    Members",($Script:htmlsb),"Unable to retrieve",$htmlwhite))    
                                                }    
                                        }    
     
                                        $msg = ""    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
                        ElseIf($? -and $Null -eq $VDIPools)    
                        {    
                                WriteHTMLLine 0 0 "No VDI Pools found for Site $($Site.Name)"    
                        }    
                        Else    
                        {    
                                WriteHTMLLine 0 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"    
                        }    
                        WriteHTMLLine 0 0 ""    
                }    
                    
                #Templates    
                    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 3 0 "Templates"    
                }    
                If($Text)    
                {    
                        Line 2 "Templates"                                           $OPTRegistryEnabled               = "False"
                }                                           $OPTVisualEffectsEnabled          = "False"
                If($HTML)                                           $OPTDiskCleanupEnabled            = "False"
                {    
                        WriteHTMLLine 3 0 "Templates"    
                }    
                    
                $VDITemplates = Get-RASVDITemplate -SiteId $Site.Id -EA 0 4>$Null    
                If($? -and $Null -ne $VDITemplates)    
                {    
                        ForEach($VDITemplate in $VDITemplates)                                           $OPTCustomScriptEnabled           = "False"
                        {    
                                $VDIHost = Get-RASProvider -Id $VDITemplate.ProviderId -EA 0 4>$Null    
                                    
                                If($? -and $null -ne $VDIHost)    
                                {    
                                        $Provider     = $VDIHost.Server    
                                        $ProviderType = GetVDIType $VDIHost.Type    
                                            
                                        #$ProviderStatus = (Get-RASProviderStatus -Id $VDITemplate.ProviderId -EA 0 4>$Null)     
 
                                ElseIf($? -$Null -eq $VDIHost) <>  
                                {    
                                        $Provider       = "No Provider found"    
                                        $ProviderType   = "Unknown"    
                                        #$ProviderStatus = "Unknown"    
                                }                           }
                                Else                           Else
                                {                           {
                                        $Provider       = "Unable to retrieve Provider with an ID of $($VDITemplate.ProviderId)"    
                                        $ProviderType   = "Unknown"    
                                        #$ProviderStatus = "Unknown"                                   #we don't inherit
                                }                                   #get the settings for the template
 
                                If($MSWord -or $PDF) <>                                 $OPTEnableOptimization            = $RDSTemplate.Optimization.EnableOptimization.ToString()
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $VDITemplate.Name; }) > $Null    
                                        #$ScriptInformation.Add(@{Data = "Status"; Value = $ProviderStatus; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Type"; Value = $VDITemplate.TemplateType.ToString(); }) > $Null                                   $OPTOptimizationType              = $RDSTemplate.Optimization.OptimizationType.ToString()
                                        $ScriptInformation.Add(@{Data = "Provider"; Value = $Provider; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Provider Type"; Value = $ProviderType; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $VDITemplate.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $VDITemplate.TimeLastMod.ToString(); }) > $Null                                   $OPTWindowsDefenderATPEnabled     = $RDSTemplate.Optimization.WindowsDefenderATPEnabled.ToString() 
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $VDITemplate.AdminCreate; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $VDITemplate.TimeCreate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $VDITemplate.Id.ToString(); }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                   $OPTWindowsComponentsEnabled      = $RDSTemplate.Optimization.WindowsComponentsEnabled.ToString()
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Name`t`t`t: " $VDITemplate.Name    
                                        #Line 3 "Status`t`t`t: " $ProviderStatus    
                                        Line 3 "Type`t`t`t: " $VDITemplate.TemplateType.ToString()    
                                        Line 3 "Provider`t`t: " $Provider    
                                        Line 3 "Provider Type`t`t: " $ProviderType    
                                        Line 3 "Last modification by`t: " $VDITemplate.AdminLastMod    
                                        Line 3 "Modified on`t`t: " $VDITemplate.TimeLastMod.ToString()    
                                        Line 3 "Created by`t`t: " $VDITemplate.AdminCreate    
                                        Line 3 "Created on`t`t: " $VDITemplate.TimeCreate.ToString()    
                                        Line 3 "ID`t`t`t: " $VDITemplate.Id.ToString()    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Name",($Script:htmlsb),$VDITemplate.Name,$htmlwhite)    
                                        #$rowdata += @(,("Status",($Script:htmlsb),$ProviderStatus,$htmlwhite))    
                                        $rowdata += @(,("Type",($Script:htmlsb),$VDITemplate.TemplateType.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Provider",($Script:htmlsb),$Provider,$htmlwhite))    
                                        $rowdata += @(,("Provider type",($Script:htmlsb),$ProviderType,$htmlwhite))    
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $VDITemplate.AdminLastMod,$htmlwhite))    
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $VDITemplate.TimeLastMod.ToString(),$htmlwhite))                                   $OPTWindowsServicesEnabled        = $RDSTemplate.Optimization.WindowsServicesEnabled.ToString()
                                        $rowdata += @(,("Created by",($Script:htmlsb), $VDITemplate.AdminCreate,$htmlwhite))                                   $OPTWinodwsScheduledTasksEnabled  = $RDSTemplate.Optimization.WindowsScheduledTasksEnabled.ToString()
                                    $OPTWindowsAdvancedOptionsEnabled = $RDSTemplate.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                        $rowdata += @(,("Created on",($Script:htmlsb), $VDITemplate.TimeCreate.ToString(),$htmlwhite))                                   $OPTNetworkPerformanceEnabled     = $RDSTemplate.Optimization.NetworkPerformanceEnabled.ToString()
                                        $rowdata += @(,("Id",($Script:htmlsb),$VDITemplate.Id.ToString(),$htmlwhite))    
     
                                        $msg = ""    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                #Properties    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "General"    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "General"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                Switch ($VDITemplate.UnusedGuestDurationMins)    
                                {    
                                        0               {$DeleteVMsTime = "Never"; Break}    
                                        1440    {$DeleteVMsTime = "1 day"; Break}    
                                        10080   {$DeleteVMsTime = "1 week"; Break}    
                                        43200   {$DeleteVMsTime = "30 days"; Break}    
                                        Default {$DeleteVMsTime = "Unable to determine Delete unused guest VMs after: $($VDITemplate.UnusedGuestDurationMins)"; Break}    
                                }    
                                    
                                Switch($VDITemplate.CloneMethod)    
                                {    
                                        "LinkedClone"   {$CloneMethod = "Create a linked clone"; Break}    
                                        "FullClone"             {$CloneMethod = "Create a full clone"; Break}    
                                        Default                 {$CloneMethod = "Unable to determine Clone method: $($VDITemplate.CloneMethod)"; Break}    
                                }    
     
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $OPTRegistryEnabled               = $RDSTemplate.Optimization.RegistryEnabled.ToString()
                                        $ScriptInformation.Add(@{Data = "Template name"; Value = $VDITemplate.Name; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Maximum guest VMs"; Value = $VDITemplate.MaxGuests.ToString(); }) > $Null                                   $OPTVisualEffectsEnabled          = $RDSTemplate.Optimization.VisualEffectsEnabled.ToString()
                                        $ScriptInformation.Add(@{Data = "Keep available buffer"; Value = $VDITemplate.PreCreatedGuests.ToString(); }) > $Null                                   $OPTDiskCleanupEnabled            = $RDSTemplate.Optimization.DiskCleanupEnabled.ToString()
                                        $ScriptInformation.Add(@{Data = "Guest VM name"; Value = $VDITemplate.GuestNameFormat; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Delete unused guest VMs after"; Value = $DeleteVMsTime; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Clone method"; Value = $CloneMethod; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                   $OPTCustomScriptEnabled           = $RDSTemplate.Optimization.CustomScriptEnabled.ToString()
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }                           }
                                If($Text)    
                                {    
                                        Line 4 "Template name`t`t`t: " $VDITemplate.Name    
                                        Line 4 "Maximum guest VMs`t`t: " $VDITemplate.MaxGuests.ToString()    
                                        Line 4 "Keep available buffer`t`t: " $VDITemplate.PreCreatedGuests.ToString()    
                                        Line 4 "Guest VM name`t`t`t: " $VDITemplate.GuestNameFormat    
                                        Line 4 "Delete unused guest VMs after`t: " $DeleteVMsTime    
                                        Line 4 "Clone method`t`t`t: " $CloneMethod    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Template name",($Script:htmlsb),$VDITemplate.Name,$htmlwhite)    
                                        $rowdata += @(,("Maximum guest VMs",($Script:htmlsb),$VDITemplate.MaxGuests.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Keep available buffer",($Script:htmlsb),$VDITemplate.PreCreatedGuests.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Guest VM name",($Script:htmlsb),$VDITemplate.GuestNameFormat,$htmlwhite))    
                                        $rowdata += @(,("Delete unused guest VMs after",($Script:htmlsb),$DeleteVMsTime,$htmlwhite))    
                                        $rowdata += @(,("Clone method",($Script:htmlsb),$CloneMethod,$htmlwhite))    
 
                                        $msg = "Properties" <>  
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                                    
                                #Advanced    
                                    
                                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                                {                           {
                                        WriteWordLine 4 0 "Advanced"    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Advanced"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                        $ScriptInformation.Add(@{Data = "Folder"; Value = $VDITemplate.FolderName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSTemplate.InheritDefaultUserProfileSettings.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Resource pool"; Value = $VDITemplate.NativePoolName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable optimization"; Value = $OPTEnableOptimization; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Physical Host"; Value = $VDITemplate.PhysicalHostName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Optimization type"; Value = $OPTOptimizationType; }) > $Null
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                        -Columns Data,Value `                                   -Columns Data,Value `
                                        -List `                                   -List `
                                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 250;
                                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                                        $Table = $Null                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                }    
                                If($Text)    
                                {    
                                        Line 4 "Folder`t`t`t`t: " $VDITemplate.FolderName    
                                        Line 4 "Resource pool`t`t`t: " $VDITemplate.NativePoolName    
                                        Line 4 "Physical Host`t`t`t: " $VDITemplate.PhysicalHostName    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Folder",($Script:htmlsb),$VDITemplate.FolderName,$htmlwhite)    
                                        $rowdata += @(,("Resource pool",($Script:htmlsb),$VDITemplate.NativePoolName,$htmlwhite))    
                                        $rowdata += @(,("Physical Host",($Script:htmlsb),$VDITemplate.PhysicalHostName,$htmlwhite))    
 
                                        $msg = "Advanced" <>                                 WriteWordLine 5 0 "Windows Defender ATP:" $OPTWindowsDefenderATPEnabled
                                        $columnWidths = @("200","275")                                   If($OPTWindowsDefenderATPEnabled -eq "True")
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                                    
                                #Preparation    
                                    
                                If($MSWord -or $PDF)    
 
                                        WriteWordLine 4 0 "Preparation" +-  
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Preparation"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                If($MSWord -or $PDF)    
                                {    
 
                                        $ScriptInformation.Add(@{Data = "Image preparation tool"; Value = $VDITemplate.ImagePrepTool.ToString(); }) > $Null <>  
                                        $ScriptInformation.Add(@{Data = "Computer name"; Value = $VDITemplate.ComputerName; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Owner name"; Value = $VDITemplate.OwnerName; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Organization"; Value = $VDITemplate.Organization; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Join domain"; Value = $VDITemplate.Domain; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Administrator"; Value = $VDITemplate.Administrator; }) > $Null                                           $ScriptInformation.Add(@{Data = "Windows Defender ATP Optimizations"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Target OU"; Value = $VDITemplate.DomainOrgUnit; }) > $Null    
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>  
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 4 "Image preparation tool`t`t: " $VDITemplate.ImagePrepTool.ToString()    
                                        Line 4 "Computer name`t`t`t: " $VDITemplate.ComputerName    
                                        Line 4 "Owner name`t`t`t: " $VDITemplate.OwnerName    
                                        Line 4 "Organization`t`t`t: " $VDITemplate.Organization    
                                        Line 4 "Join domain`t`t`t: " $VDITemplate.Domain    
                                        Line 4 "Administrator`t`t`t: " $VDITemplate.Administrator    
                                        Line 4 "Target OU`t`t`t: " $VDITemplate.DomainOrgUnit    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Image preparation tool",($Script:htmlsb),$VDITemplate.ImagePrepTool.ToString(),$htmlwhite)    
                                        $rowdata += @(,("Computer name",($Script:htmlsb),$VDITemplate.ComputerName,$htmlwhite))    
                                        $rowdata += @(,("Owner name",($Script:htmlsb),$VDITemplate.OwnerName,$htmlwhite))    
                                        $rowdata += @(,("Organization",($Script:htmlsb),$VDITemplate.Organization,$htmlwhite))    
                                        $rowdata += @(,("Join domain",($Script:htmlsb),$VDITemplate.Domain,$htmlwhite))    
                                        $rowdata += @(,("Administrator",($Script:htmlsb),$VDITemplate.Administrator,$htmlwhite))    
                                        $rowdata += @(,("Target OU",($Script:htmlsb),$VDITemplate.DomainOrgUnit,$htmlwhite))    
     
                                        $msg = "Preparation"    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                #User Profile    
                                #There is no way to retrieve the settings if "Inherit default settings" is selected.    
                                #There is also no way to retrieve the Site Defaults, which are more than User profile settings    
                                #I will leave this code in but commented out    
                            
                                <#If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "User profile"    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "User profile"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
     
                                If($VDITemplate.InheritDefUserProfileSettings)    
                                {    
                                        #do we inherit site defaults?    
                                        #yes we do, get the default settings for the Site    
                                        #use the Site default settings    
                                            
                                        #Template technology settings do not include UPD, only FSLogix    
                                        $TemplateDefaults = Get-RASRDSDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                            
                                        If($? -and $Null -ne $TemplateDefaults)    
                                        {    
                                                Switch ($TemplateDefaults.Technology)    
                                                {    
                                                        "DoNotManage"                           {$TemplateTechnology = "Do not manage by RAS"; Break}    
                                                        "FSLogixProfileContainer"       {$TemplateTechnology = "FSLogix"; Break}    
                                                        Default                                         {$TemplateTechnology = "Unable to determine Technology State: $($TemplateDefaults.Technology)"; Break}    
                                                }    
                                                    
                                                $FSLogixSettings           = $TemplateDefaults.FSLogix.ProfileContainer    
                                                $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id}    
                                                    
                                                Switch($FSLogixDeploymentSettings.InstallType)    
                                                {    
                                                        "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}    
                                                        "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}    
                                                        "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}    
                                                        "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}    
                                                        Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}    
                                                }    
                                                    
                                                $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL    
                                                $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath    
                                                $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName    
                                                $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate    
     
                                                Switch ($FSLogixSettings.LocationType)    
                                                {    
                                                        "SMBLocation"       
                                                        {    
                                                                $FSLogixLocationType = "SMB Location"    
                                                                $FSLogixLocationOfProfileDisks = $FSLogixSettings.VHDLocations    
                                                                Break    
                                                        }    
                                                        "CloudCache"        
                                                        {    
                                                                $FSLogixLocationType = "Cloud Cache"    
                                                                $FSLogixLocationOfProfileDisks = $FSLogixSettings.CCDLocations    
                                                                Break    
                                                        }    
                                                        Default                     
                                                        {    
                                                                $FSLogixLocationType = "Unable to determine FSLogix Location type: $($FSLogixSettings.LocationType)"    
                                                                $FSLogixLocationOfProfileDisks = @()    
                                                                Break    
                                                        }    
                                                }    
                                                    
                                                Switch ($FSLogixSettings.ProfileDiskFormat)    
                                                {    
                                                        "VHD"   {$FSLogixProfileDiskFormat = "VHD"; Break}    
                                                        "VHDX"  {$FSLogixProfileDiskFormat = "VHDX"; Break}    
                                                        Default {$FSLogixProfileDiskFormat = "Unable to determine FSLogix Profile disk format: $($FSLogixSettings.ProfileDiskFormat)"; Break}    
                                                }    
                                                    
                                                Switch ($FSLogixSettings.AllocationType)    
                                                {    
                                                        "Dynamic"       {$FSLogixAllocationType = "Dynamic"; Break}    
                                                        "Full"          {$FSLogixAllocationType = "Full"; Break}    
                                                        Default         {$FSLogixAllocationType = "Unable to determine FSLogix Allocation type: $($FSLogixSettings.AllocationType)"; Break}    
                                                }    
                                                    
                                                $FSLogixDefaultSize = $FSLogixSettings.DefaultSize.ToString()    
                                                            
                                                #FSLogix Additional settings    
                                                #Users and Groups tab    
                                                If($FSLogixSettings.UserInclusionList.Count -eq 0)    
                                                {    
                                                        $FSLogixSettingsUserInclusionList = @("Everyone")    
                                                }    
                                                Else    
                                                {    
                                                        $FSLogixSettingsUserInclusionList = $FSLogixSettings.UserInclusionList    
                                                }    
                                                $FSLogixSettingsUserExclusionList       = $FSLogixSettings.UserExclusionList    
                                                            
                                                #Folders tab    
                                                $FSLogixSettingsCustomizeProfileFolders = $FSLogixSettings.CustomizeProfileFolders    
                                                $FSLogixSettingsExcludeCommonFolders    = $FSLogixSettings | Select-Object -ExpandProperty ExcludeCommonFolders    
                                                $ExcludedCommonFolders                  = @()    
                                                $FSLogixSettingsFolderInclusionList     = $FSLogixSettings.FolderInclusionList    
                                                $FSLogixSettingsFolderExclusionList     = $FSLogixSettings.FolderExclusionList    
     
                                                If($FSLogixSettingsCustomizeProfileFolders)    
                                                {    
                                                        #####################################################################################    
                                                        #MANY thanks to Guy Leech for helping me figure out how to process and use this Enum#    
                                                        #####################################################################################    
     
                                                        #this is cumulative    
                                                        #Contacts, Desktop, Documents, Links, MusicPodcasts, PicturesVideos, FoldersLowIntegProcesses    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Contacts)    
                                                        {    
                                                                $ExcludedCommonFolders += "Contacts"    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Desktop)    
                                                        {    
                                                                $ExcludedCommonFolders += "Desktop"    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Documents)    
                                                        {    
                                                                $ExcludedCommonFolders += "Documents"    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Links)    
                                                        {    
                                                                $ExcludedCommonFolders += "Links"    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::MusicPodcasts)    
                                                        {    
                                                                $ExcludedCommonFolders += 'Music & Podcasts'    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::PicturesVideos)    
                                                        {    
                                                                $ExcludedCommonFolders += 'Pictures & Videos'    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::FoldersLowIntegProcesses)    
                                                        {    
                                                                $ExcludedCommonFolders += "Folders used by Low Integrity processes"    
                                                        }    
                                                }    
                                                            
                                                #Advanced tab    
                                                $FSLogixAS = $FSLogixSettings.AdvancedSettings    
                                                    
                                                Switch($FSLogixAS.AccessNetworkAsComputerObject)    
                                                {    
                                                        "Enable"        {$FSLogixAS_AccessNetworkAsComputerObject = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_AccessNetworkAsComputerObject = "Disable"; Break}    
                                                        Default         {$FSLogixAS_AccessNetworkAsComputerObject = "Unknown: $($FSLogixAS.AccessNetworkAsComputerObject)"; Break}    
                                                }    
                                                    
                                                $FSLogixAS_AttachVHDSDDL = $FSLogixAS.AttachVHDSDDL    
                                                    
                                                Switch($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)    
                                                {    
                                                        "Enable"        {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"; Break}    
                                                        Default         {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Unknown: $($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)"; Break}    
                                                }    
     
                                                $FSLogixAS_DiffDiskParentFolderPath = $FSLogixAS.DiffDiskParentFolderPath      
     
                                                Switch($FSLogixAS.FlipFlopProfileDirectoryName)    
                                                {    
                                                        "Enable"        {$FSLogixAS_FlipFlopProfileDirectoryName = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_FlipFlopProfileDirectoryName = "Disable"; Break}    
                                                        Default         {$FSLogixAS_FlipFlopProfileDirectoryName = "Unknown: $($FSLogixAS.FlipFlopProfileDirectoryName)"; Break}    
                                                }    
                                                    
                                                Switch($FSLogixAS.KeepLocalDir)    
                                                {    
                                                        "Enable"        {$FSLogixAS_KeepLocalDir = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_KeepLocalDir = "Disable"; Break}    
                                                        Default         {$FSLogixAS_KeepLocalDir = "Unknown: $($FSLogixAS.KeepLocalDir)"; Break}    
                                                }    
     
                                                $FSLogixAS_LockedRetryCount    = $FSLogixAS.LockedRetryCount                           
                                                $FSLogixAS_LockedRetryInterval = $FSLogixAS.LockedRetryInterval         
                                                    
                                                Switch($FSLogixAS.NoProfileContainingFolder)    
                                                {    
                                                        "Enable"        {$FSLogixAS_NoProfileContainingFolder = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_NoProfileContainingFolder = "Disable"; Break}    
                                                        Default         {$FSLogixAS_NoProfileContainingFolder = "Unknown: $($FSLogixAS.NoProfileContainingFolder)"; Break}    
                                                }    
     
                                                Switch($FSLogixAS.OutlookCachedMode)    
                                                {    
                                                        "Enable"        {$FSLogixAS_OutlookCachedMode = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_OutlookCachedMode = "Disable"; Break}    
                                                        Default         {$FSLogixAS_OutlookCachedMode = "Unknown: $($FSLogixAS.OutlookCachedMode)"; Break}    
                                                }    
     
                                                Switch($FSLogixAS.PreventLoginWithFailure)    
                                                {    
                                                        "Enable"        {$FSLogixAS_PreventLoginWithFailure = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_PreventLoginWithFailure = "Disable"; Break}    
                                                        Default         {$FSLogixAS_PreventLoginWithFailure = "Unknown: $($FSLogixAS.PreventLoginWithFailure)"; Break}    
                                                }    
     
                                                Switch($FSLogixAS.PreventLoginWithTempProfile)    
                                                {    
                                                        "Enable"        {$FSLogixAS_PreventLoginWithTempProfile = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_PreventLoginWithTempProfile = "Disable"; Break}    
                                                        Default         {$FSLogixAS_PreventLoginWithTempProfile = "Unknown: $($FSLogixAS.PreventLoginWithTempProfile)"; Break}                                           If($RDSTemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                                }    
     
                                                $FSLogixAS_ProfileDirSDDL = $FSLogixAS.ProfileDirSDDL    
     
                                                Switch($FSLogixAS.ProfileType)    
                                                {    
                                                        "NormalProfile" {$FSLogixAS_ProfileType = "Normal profile"; Break}    
                                                        "OnlyRWProfile" {$FSLogixAS_ProfileType = "Only RW profile"; Break}    
                                                        "OnlyROProfile" {$FSLogixAS_ProfileType = "Only RO profile"; Break}    
                                                        "RWROProfile"   {$FSLogixAS_ProfileType = "RW/RO profile"; Break}    
                                                        Default                 {$FSLogixAS_ProfileType = "Unknown: $($FSLogixAS.ProfileType)"; Break}    
                                                }    
     
                                                $FSLogixAS_ReAttachIntervalSeconds = $FSLogixAS.ReAttachIntervalSeconds                    
                                                $FSLogixAS_ReAttachRetryCount      = $FSLogixAS.ReAttachRetryCount                         
     
                                                Switch($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)    
                                                {    
                                                        "Enable"        {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Disable"; Break}    
                                                        Default         {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Unknown: $($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)"; Break}    
                                                }    
     
                                                Switch($FSLogixAS.RoamSearch)    
                                                {    
                                                        "Enable"        {$FSLogixAS_RoamSearch = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_RoamSearch = "Disable"; Break}    
                                                        Default         {$FSLogixAS_RoamSearch = "Unknown: $($FSLogixAS.RoamSearch)"; Break}    
                                                }    
     
                                                Switch($FSLogixAS.SetTempToLocalPath)    
                                                {    
                                                        "TakeNoAction"                                  {$FSLogixAS_SetTempToLocalPath = "Take no action"; Break}    
                                                        "RedirectTempAndTmp"                    {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP and TMP"; Break}    
                                                        "RedirectINetCache"                             {$FSLogixAS_SetTempToLocalPath = "Redirect INetCache"; Break}    
                                                        "RedirectTempTmpAndINetCache"   {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP, TMP, and INetCache"; Break}    
                                                        Default                                                 {$FSLogixAS_SetTempToLocalPath = "Unknown: $($FSLogixAS.SetTempToLocalPath)"; Break}    
                                                }    
     
                                                $FSLogixAS_SIDDirNameMatch   = $FSLogixAS.SIDDirNameMatch                            
                                                $FSLogixAS_SIDDirNamePattern = $FSLogixAS.SIDDirNamePattern                          
                                                $FSLogixAS_SIDDirSDDL        = $FSLogixAS.SIDDirSDDL    
                                                $FSLogixAS_VHDNameMatch      = $FSLogixAS.VHDNameMatch                               
                                                $FSLogixAS_VHDNamePattern    = $FSLogixAS.VHDNamePattern                             
     
                                                Switch($FSLogixAS.VHDXSectorSize)    
                                                {    
                                                        0               {$FSLogixAS_VHDXSectorSize = "System default"; Break}    
                                                        512             {$FSLogixAS_VHDXSectorSize = "512"; Break}    
                                                        4096    {$FSLogixAS_VHDXSectorSize = "4096"; Break}    
                                                        Default {$FSLogixAS_VHDXSectorSize = "Unknown: $($FSLogixAS.VHDXSectorSize)"; Break}    
                                                }    
     
                                                $FSLogixAS_VolumeWaitTimeMS = $FSLogixAS.VolumeWaitTimeMS                                                                   
                                        }    
                                        Else    
 
                                                #unable to retrieve default, use built-in default values <>  
                                                $TemplateTechnology                             = "Do not manage by RAS"    
                                                $FSLogixDeploymentSettingsDeploymentMethod      = "None"    
                                                $FSLogixDeploymentSettingsInstallOnlineURL      = "None"    
                                                $FSLogixDeploymentSettingsNetworkDrivePath      = "None"    
                                                $FSLogixDeploymentSettingsInstallerFileName     = "None"    
                                                $FSLogixDeploymentSettingsReplicate             = $False    
                                                $FSLogixLocationType                            = "None"    
                                                $FSLogixLocationOfProfileDisks                  = @()    
                                                $FSLogixProfileDiskFormat                       = "None"    
                                                $FSLogixAllocationType                          = "None"    
                                                $FSLogixDefaultSize                             = "0"    
                                                $FSLogixSettingsUserInclusionList               = @("Everyone")    
                                                $FSLogixSettingsUserExclusionList               = @()    
                                                $FSLogixSettingsCustomizeProfileFolders         = $False    
                                                $FSLogixSettingsExcludeCommonFolders            = "None"    
                                                $ExcludedCommonFolders                          = @()    
                                                $FSLogixSettingsFolderInclusionList             = @()    
                                                $FSLogixSettingsFolderExclusionList             = @()    
                                                $FSLogixAS_AccessNetworkAsComputerObject        = "Disable"    
                                                $FSLogixAS_AttachVHDSDDL                        = "None"    
                                                $FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"    
                                                $FSLogixAS_DiffDiskParentFolderPath             = "%TEMP"    
                                                $FSLogixAS_FlipFlopProfileDirectoryName         = "Disable"    
                                                $FSLogixAS_KeepLocalDir                         = "Disable"    
                                                $FSLogixAS_LockedRetryCount                     = 12    
                                                $FSLogixAS_LockedRetryInterval                  = 5    
                                                $FSLogixAS_NoProfileContainingFolder            = "Disable"    
                                                $FSLogixAS_OutlookCachedMode                    = "Disable"    
                                                $FSLogixAS_PreventLoginWithFailure              = "Disable"    
                                                $FSLogixAS_PreventLoginWithTempProfile          = "Disable"    
                                                $FSLogixAS_ProfileDirSDDL                       = "None"    
                                                $FSLogixAS_ProfileType                          = "Normal profile"    
                                                $FSLogixAS_ReAttachIntervalSeconds              = 10    
                                                $FSLogixAS_ReAttachRetryCount                   = 60    
                                                $FSLogixAS_RemoveOrphanedOSTFilesOnLogoff       = "Enable"    
                                                $FSLogixAS_RoamSearch                           = "Disable"    
                                                $FSLogixAS_SetTempToLocalPath                   = "Redirect TEMP, TMP, and INetCache"    
                                                $FSLogixAS_SIDDirNameMatch                      = "%sid%_%username%"    
                                                $FSLogixAS_SIDDirNamePattern                    = "%sid%_%username%"    
                                                $FSLogixAS_SIDDirSDDL                           = "None"    
                                                $FSLogixAS_VHDNameMatch                         = "Profile*"    
                                                $FSLogixAS_VHDNamePattern                       = "Profile_%username%"    
                                                $FSLogixAS_VHDXSectorSize                       = "System default"    
                                                $FSLogixAS_VolumeWaitTimeMS                     = 20000    
                                        }    
                                }    
                                Else    
                                {    
                                        #we don't inherit    
                                        #get the settings for the template    
     
                                        Switch ($VDITemplate.Technology)    
                                        {    
                                                "DoNotManage"                           {$TemplateTechnology = "Do not manage by RAS"; Break}    
                                                "FSLogixProfileContainer"       {$TemplateTechnology = "FSLogix"; Break}    
                                                Default                                         {$TemplateTechnology = "Unable to determine Technology State: $($TemplateDefaults.Technology)"; Break}    
                                        }    
                                                            
                                        $FSLogixSettings           = $VDITemplate.FSLogix.ProfileContainer    
                                        $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id}    
                                            
                                        Switch($FSLogixDeploymentSettings.InstallType)    
                                        {    
                                                "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}    
                                                "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}    
                                                "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}    
                                                "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}                                                   $ScriptInformation.Add(@{Data = "     Turn off Windows Defender ATP (I use my own ATP solution)"; Value = ""; }) > $Null
                                                Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}    
 
                                         +-  
                                        $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL    
                                        $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath    
                                        $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName    
                                        $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate    
                                            
                                        Switch ($FSLogixSettings.LocationType)    
                                        {    
                                                "SMBLocation"       
                                                {    
                                                        $FSLogixLocationType = "SMB Location"    
                                                        $FSLogixLocationOfProfileDisks = $FSLogixSettings.VHDLocations    
                                                        Break    
                                                }    
                                                "CloudCache"        
                                                {    
                                                        $FSLogixLocationType = "Cloud Cache"    
                                                        $FSLogixLocationOfProfileDisks = $FSLogixSettings.CCDLocations    
                                                        Break    
                                                }    
                                                Default                     
                                                {    
                                                        $FSLogixLocationType = "Unable to determine FSLogix Location type: $($FSLogixSettings.LocationType)"    
                                                        $FSLogixLocationOfProfileDisks = @()    
                                                        Break    
                                                }    
                                        }    
                                            
                                        Switch ($FSLogixSettings.ProfileDiskFormat)    
                                        {    
                                                "VHD"   {$FSLogixProfileDiskFormat = "VHD"; Break}    
                                                "VHDX"  {$FSLogixProfileDiskFormat = "VHDX"; Break}    
                                                Default {$FSLogixProfileDiskFormat = "Unable to determine FSLogix Profile disk format: $($FSLogixSettings.ProfileDiskFormat)"; Break}    
                                        }    
                                            
                                        Switch ($FSLogixSettings.AllocationType)    
                                        {    
                                                "Dynamic"       {$FSLogixAllocationType = "Dynamic"; Break}    
                                                "Full"          {$FSLogixAllocationType = "Full"; Break}    
                                                Default         {$FSLogixAllocationType = "Unable to determine FSLogix Allocation type: $($FSLogixSettings.AllocationType)"; Break}    
                                        }    
                                            
                                        $FSLogixDefaultSize = $FSLogixSettings.DefaultSize.ToString()    
                                                            
                                        #FSLogix Additional settings    
                                        #Users and Groups tab    
                                        If($FSLogixSettings.UserInclusionList.Count -eq 0)    
                                        {    
                                                $FSLogixSettingsUserInclusionList = @("Everyone")    
                                        }    
 
                                                $FSLogixSettingsUserInclusionList = $FSLogixSettings.UserInclusionList <>  
                                        }    
                                        $FSLogixSettingsUserExclusionList       = $FSLogixSettings.UserExclusionList    
                                                            
                                        #Folders tab    
                                        $FSLogixSettingsCustomizeProfileFolders = $FSLogixSettings.CustomizeProfileFolders    
                                        $FSLogixSettingsExcludeCommonFolders    = $FSLogixSettings | Select-Object -ExpandProperty ExcludeCommonFolders    
                                        $ExcludedCommonFolders                  = @()    
                                        $FSLogixSettingsFolderInclusionList     = $FSLogixSettings.FolderInclusionList    
                                        $FSLogixSettingsFolderExclusionList     = $FSLogixSettings.FolderExclusionList    
     
                                        If($FSLogixSettingsCustomizeProfileFolders)    
                                        {    
                                                #####################################################################################    
                                                #MANY thanks to Guy Leech for helping me figure out how to process and use this Enum#    
                                                #####################################################################################    
     
                                                #this is cumulative    
                                                #Contacts, Desktop, Documents, Links, MusicPodcasts, PicturesVideos, FoldersLowIntegProcesses    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Contacts)    
                                                {    
                                                        $ExcludedCommonFolders += "Contacts"    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Desktop)    
                                                {    
                                                        $ExcludedCommonFolders += "Desktop"    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Documents)    
                                                {    
                                                        $ExcludedCommonFolders += "Documents"    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Links)    
                                                {    
                                                        $ExcludedCommonFolders += "Links"    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::MusicPodcasts)    
                                                {    
                                                        $ExcludedCommonFolders += 'Music & Podcasts'    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::PicturesVideos)    
                                                {    
                                                        $ExcludedCommonFolders += 'Pictures & Videos'    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::FoldersLowIntegProcesses)    
                                                {    
                                                        $ExcludedCommonFolders += "Folders used by Low Integrity processes"    
                                                }    
                                        }    
                                            
                                        #Advanced tab    
                                        $FSLogixAS = $FSLogixSettings.AdvancedSettings    
                                            
                                        Switch($FSLogixAS.AccessNetworkAsComputerObject)    
                                        {    
                                                "Enable"        {$FSLogixAS_AccessNetworkAsComputerObject = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_AccessNetworkAsComputerObject = "Disable"; Break}    
                                                Default         {$FSLogixAS_AccessNetworkAsComputerObject = "Unknown: $($FSLogixAS.AccessNetworkAsComputerObject)"; Break}    
                                        }    
                                            
                                        $FSLogixAS_AttachVHDSDDL = $FSLogixAS.AttachVHDSDDL    
                                            
                                        Switch($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)    
                                        {    
                                                "Enable"        {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"; Break}    
                                                Default         {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Unknown: $($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)"; Break}    
                                        }    
     
                                        $FSLogixAS_DiffDiskParentFolderPath = $FSLogixAS.DiffDiskParentFolderPath      
     
                                        Switch($FSLogixAS.FlipFlopProfileDirectoryName)    
                                        {    
                                                "Enable"        {$FSLogixAS_FlipFlopProfileDirectoryName = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_FlipFlopProfileDirectoryName = "Disable"; Break}    
                                                Default         {$FSLogixAS_FlipFlopProfileDirectoryName = "Unknown: $($FSLogixAS.FlipFlopProfileDirectoryName)"; Break}    
                                        }    
                                            
                                        Switch($FSLogixAS.KeepLocalDir)    
                                        {    
                                                "Enable"        {$FSLogixAS_KeepLocalDir = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_KeepLocalDir = "Disable"; Break}    
                                                Default         {$FSLogixAS_KeepLocalDir = "Unknown: $($FSLogixAS.KeepLocalDir)"; Break}    
                                        }    
     
                                        $FSLogixAS_LockedRetryCount    = $FSLogixAS.LockedRetryCount                           
                                        $FSLogixAS_LockedRetryInterval = $FSLogixAS.LockedRetryInterval         
                                            
                                        Switch($FSLogixAS.NoProfileContainingFolder)    
                                        {    
                                                "Enable"        {$FSLogixAS_NoProfileContainingFolder = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_NoProfileContainingFolder = "Disable"; Break}    
                                                Default         {$FSLogixAS_NoProfileContainingFolder = "Unknown: $($FSLogixAS.NoProfileContainingFolder)"; Break}    
                                        }    
     
                                        Switch($FSLogixAS.OutlookCachedMode)    
                                        {    
                                                "Enable"        {$FSLogixAS_OutlookCachedMode = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_OutlookCachedMode = "Disable"; Break}    
                                                Default         {$FSLogixAS_OutlookCachedMode = "Unknown: $($FSLogixAS.OutlookCachedMode)"; Break}    
                                        }    
     
                                        Switch($FSLogixAS.PreventLoginWithFailure)    
                                        {    
                                                "Enable"        {$FSLogixAS_PreventLoginWithFailure = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_PreventLoginWithFailure = "Disable"; Break}    
                                                Default         {$FSLogixAS_PreventLoginWithFailure = "Unknown: $($FSLogixAS.PreventLoginWithFailure)"; Break}    
                                        }    
     
                                        Switch($FSLogixAS.PreventLoginWithTempProfile)    
                                        {    
                                                "Enable"        {$FSLogixAS_PreventLoginWithTempProfile = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_PreventLoginWithTempProfile = "Disable"; Break}    
                                                Default         {$FSLogixAS_PreventLoginWithTempProfile = "Unknown: $($FSLogixAS.PreventLoginWithTempProfile)"; Break}    
                                        }    
     
                                        $FSLogixAS_ProfileDirSDDL = $FSLogixAS.ProfileDirSDDL    
     
                                        Switch($FSLogixAS.ProfileType)    
                                        {    
                                                "NormalProfile" {$FSLogixAS_ProfileType = "Normal profile"; Break}    
                                                "OnlyRWProfile" {$FSLogixAS_ProfileType = "Only RW profile"; Break}    
                                                "OnlyROProfile" {$FSLogixAS_ProfileType = "Only RO profile"; Break}    
                                                "RWROProfile"   {$FSLogixAS_ProfileType = "RW/RO profile"; Break}    
                                                Default         {$FSLogixAS_ProfileType = "Unknown: $($FSLogixAS.ProfileType)"; Break}    
                                        }    
     
                                        $FSLogixAS_ReAttachIntervalSeconds = $FSLogixAS.ReAttachIntervalSeconds                    
                                        $FSLogixAS_ReAttachRetryCount      = $FSLogixAS.ReAttachRetryCount                         
     
                                        Switch($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)    
                                        {    
                                                "Enable"        {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Disable"; Break}    
                                                Default         {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Unknown: $($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)"; Break}    
                                        }    
     
                                        Switch($FSLogixAS.RoamSearch)    
                                        {    
                                                "Enable"        {$FSLogixAS_RoamSearch = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_RoamSearch = "Disable"; Break}    
                                                Default         {$FSLogixAS_RoamSearch = "Unknown: $($FSLogixAS.RoamSearch)"; Break}    
                                        }    
     
                                        Switch($FSLogixAS.SetTempToLocalPath)    
                                        {    
                                                "TakeNoAction"                                  {$FSLogixAS_SetTempToLocalPath = "Take no action"; Break}    
                                                "RedirectTempAndTmp"                    {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP and TMP"; Break}    
                                                "RedirectINetCache"                             {$FSLogixAS_SetTempToLocalPath = "Redirect INetCache"; Break}    
                                                "RedirectTempTmpAndINetCache"   {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP, TMP, and INetCache"; Break}    
                                                Default                                                 {$FSLogixAS_SetTempToLocalPath = "Unknown: $($FSLogixAS.SetTempToLocalPath)"; Break}    
                                        }    
     
                                        $FSLogixAS_SIDDirNameMatch   = $FSLogixAS.SIDDirNameMatch                            
                                        $FSLogixAS_SIDDirNamePattern = $FSLogixAS.SIDDirNamePattern                          
                                        $FSLogixAS_SIDDirSDDL        = $FSLogixAS.SIDDirSDDL    
                                        $FSLogixAS_VHDNameMatch      = $FSLogixAS.VHDNameMatch                               
                                        $FSLogixAS_VHDNamePattern    = $FSLogixAS.VHDNamePattern                             
     
                                        Switch($FSLogixAS.VHDXSectorSize)    
                                        {    
                                                0               {$FSLogixAS_VHDXSectorSize = "System default"; Break}    
                                                512             {$FSLogixAS_VHDXSectorSize = "512"; Break}    
                                                4096    {$FSLogixAS_VHDXSectorSize = "4096"; Break}    
                                                Default {$FSLogixAS_VHDXSectorSize = "Unknown: $($FSLogixAS.VHDXSectorSize)"; Break}    
                                        }    
     
                                        $FSLogixAS_VolumeWaitTimeMS = $FSLogixAS.VolumeWaitTimeMS                                                                   
                                }    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefUserProfileSettings.ToString(); }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Turn on Windows Defender ATP and set process and folder exclusions"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Technology"; Value = $TemplateTechnology; }) > $Null    
     
                                        If($TemplateTechnology -eq "Do not manage by RAS")    
                                        {    
                                                #do nothing    
                                        }    
                                        ElseIf($TemplateTechnology -eq "FSLogix")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Deployment method"; Value = $FSLogixDeploymentSettingsDeploymentMethod; }) > $Null    
                                                If($FSLogixDeploymentSettings.InstallType -eq "Online")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "URL"; Value = $FSLogixDeploymentSettingsInstallOnlineURL; }) > $Null    
                                                }    
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsNetworkDrivePath; }) > $Null    
                                                }    
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsInstallerFileName; }) > $Null    
                                                }    
                                                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Disable real-time protection"; Value = $RDSTemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(); }) > $Null
                                                $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Location type"; Value = $FSLogixLocationType; }) > $Null    
 
                                                ForEach($item in $FSLogixLocationOfProfileDisks) <>                                                 ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
 
                                                         +-  
 
                                                                $ScriptInformation.Add(@{Data = "     Location of profile disks"; Value = $item; }) > $Null <>                                                                 $ScriptInformation.Add(@{Data = "     Exclude files and folders"; Value = $item; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = "     Profile disk format"; Value = $FSLogixProfileDiskFormat; }) > $Null +-  
                                                $ScriptInformation.Add(@{Data = "     Allocation type"; Value = $FSLogixAllocationType; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "     Default size"; Value = "$FSLogixDefaultSize GB"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Additional settings"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "     Users and Groups"; Value = ""; }) > $Null    
                                                    
                                                If($FSLogixSettingsUserInclusionList.Count -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          User Inclusion List"; Value = "None"; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $cnt = -1    
                                                        ForEach($item in $FSLogixSettingsUserInclusionList)    
                                                        {    
                                                                $cnt++    
                                                                    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "          User Inclusion List"; Value = "User: $($item.Account)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "User: $($item.Account)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                                }    
                                                        }    
                                                }    
 
                                                If($FSLogixSettingsUserExclusionList.Count -eq 0) <>  
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = ""; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $cnt = -1                                                   $cnt = -1
                                                        ForEach($item in $FSLogixSettingsUserExclusionList)    
                                                        {    
                                                                $cnt++    
                                                                    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        #$ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = "User: $($item.Account)  Type: $($item.Type)"; }) > $Null                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                                        $ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = "User: $($item.Account)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "User: $($item.Account)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                                }    
                                                        }    
                                                }    
                                                $ScriptInformation.Add(@{Data = "     Folders"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Customize profile folders"; Value = $FSLogixSettingsCustomizeProfileFolders.ToString(); }) > $Null    
                                                If($FSLogixSettingsCustomizeProfileFolders)    
 
                                                        If($ExcludedCommonFolders.Count -gt 0) <>  
                                                        {    
                                                                $cnt = -1    
                                                                ForEach($item in $ExcludedCommonFolders)    
                                                                {    
                                                                        $cnt++                                                           $cnt++
                                                                            
                                                                        If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                                        {                                                           {
                                                                                $ScriptInformation.Add(@{Data = "               Exclude Common Folders"; Value = $item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = "     Exclude processes"; Value = $item; }) > $Null
                                                                        }                                                           }
                                                                        Else                                                           Else
                                                                        {                                                           {
                                                                                $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                        }    
                                                                }    
 
                                                        Else +-  
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "               Exclude Common Folders"; Value = "None"; }) > $Null    
                                                        }    
 
  <>  
                                                If($FSLogixSettingsFolderInclusionList.Count -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          Folder Inclusion List"; Value = "None"; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          Folder Inclusion List"; Value = ""; }) > $Null    
                                                        $cnt = -1    
                                                        ForEach($item in $FSLogixSettingsFolderInclusionList)    
                                                        {    
                                                                $cnt++    
                                                                                                                  
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "               Folder"; Value = "$item"; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "$item"; }) > $Null    
                                                                }    
                                                        }    
                                                }    
     
                                                If($FSLogixSettingsFolderExclusionList.Count -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          Folder Exclusion List"; Value = "None"; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          Folder Exclusion List"; Value = ""; }) > $Null    
                                                        $cnt = -1                                                   $cnt = -1
                                                        ForEach($item in $FSLogixSettingsFolderExclusionList)                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                        {                                                   {
                                                                $cnt++                                                           $cnt++
                                                                    
                                                                Switch($item.ExcludeFolderCopy)    
                                                                {    
                                                                        "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}    
                                                                        "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}    
                                                                        "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}    
                                                                        "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}    
                                                                        Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}    
                                                                }    
                                                                    
                                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                                {                                                           {
                                                                        $ScriptInformation.Add(@{Data = "               Folder"; Value = "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"; }) > $Null                                                                   $ScriptInformation.Add(@{Data = "     Exclude extensions"; Value = $item; }) > $Null
                                                                }                                                           }
                                                                Else                                                           Else
                                                                {                                                           {
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                }    
 
                                                 +-  
                                                $ScriptInformation.Add(@{Data = "     Advanced"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          FSLogix Setting:"; Value = "Value:"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Access network as computer object"; Value = "$($FSLogixAS_AccessNetworkAsComputerObject)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Custom SDDL for profile directory"; Value = "$($FSLogixAS_ProfileDirSDDL)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Delay between locked VHD(X) retries"; Value = "$($FSLogixAS_LockedRetryInterval)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Delete local profile when loading from VHD"; Value = "$($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Diff disk parent folder path"; Value = "$($FSLogixAS_DiffDiskParentFolderPath)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Do not create a folder for new profiles"; Value = "$($FSLogixAS_NoProfileContainingFolder)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Enable Cached mode for Outlook"; Value = "$($FSLogixAS_OutlookCachedMode)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Keep local profiles"; Value = "$($FSLogixAS_KeepLocalDir)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Naming pattern for new VHD(X) files"; Value = "$($FSLogixAS_VHDNamePattern)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Number of locked VHD(X) retries"; Value = "$($FSLogixAS_LockedRetryCount)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Prevent logons with failures"; Value = "$($FSLogixAS_PreventLoginWithFailure)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Prevent logons with temp profiles"; Value = "$($FSLogixAS_PreventLoginWithTempProfile)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Profile folder naming pattern"; Value = "$($FSLogixAS_SIDDirNameMatch)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Profile type"; Value = "$($FSLogixAS_ProfileType)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Profile VHD(X) file matching pattern"; Value = "$($FSLogixAS_VHDNameMatch)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Re-attach interval"; Value = "$($FSLogixAS_ReAttachIntervalSeconds)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Re-attach retry limit"; Value = "$($FSLogixAS_ReAttachRetryCount)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Remove duplicate OST files on logoff"; Value = "$($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          SDDL used when attaching the VHD"; Value = "$($FSLogixAS_AttachVHDSDDL)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Search roaming feature mode"; Value = "$($FSLogixAS_RoamSearch)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Swap SID and username in profile directory names"; Value = "$($FSLogixAS_FlipFlopProfileDirectoryName)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Temporary folders redirection mode"; Value = "$($FSLogixAS_SetTempToLocalPath)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Use SDDL on creation of SID containing folder"; Value = "$($FSLogixAS_SIDDirSDDL)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          User-to-Profile matching pattern"; Value = "$($FSLogixAS_SIDDirNamePattern)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          VHDX sector size"; Value = "$($FSLogixAS_VHDXSectorSize)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Volume wait time"; Value = "$($FSLogixAS_VolumeWaitTimeMS)"; }) > $Null    
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite +-  
 
                                If($Text) <>  
                                    WriteWordLine 5 0 "Windows Components:" $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
 
                                        Line 3 "Inherit default settings`t`t`t`t: " $VDITemplate.InheritDefUserProfileSettings.ToString() <>                                         $ScriptInformation = New-Object System.Collections.ArrayList
                                        Line 3 "Technology`t`t`t`t`t`t: " $TemplateTechnology                                           $ScriptInformation.Add(@{Data = "Windows Components Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable (remove) components:"; Value = ""; }) > $Null
 
                                        If($TemplateTechnology -eq "Do not manage by RAS") <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            ForEach($item in $RDSTemplate.Optimization.WindowsComponents.WindowsComponentsList)
 
                                                #do nothing <>                                                         If($Null -eq $item.DisplayName)
                                                            {
                                                                    $DisplayName = ""
                                        }                                                           }
                                        ElseIf($TemplateTechnology -eq "FSLogix")                                                           Else
                                        {                                                           {
                                                Line 3 "Deployment method`t`t`t`t`t: " $FSLogixDeploymentSettingsDeploymentMethod                                                                   $DisplayName = $item.DisplayName
                                                If($FSLogixDeploymentSettings.InstallType -eq "Online")                                                           }
                                                            If($Null -eq $item.ComponentName)
                                                {                                                           {
                                                        Line 3 "URL`t`t`t`t`t`t`t: " $FSLogixDeploymentSettingsInstallOnlineURL                                                                   $ComponentName = ""
                                                }                                                           }
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")                                                           Else
                                                {                                                           {
                                                        Line 10 ": " $FSLogixDeploymentSettingsNetworkDrivePath                                                                   $ComponentName = $item.ComponentName
                                                            }
                                                    $OptimizationTable += @{
                                                            DisplayName = $DisplayName
                                                            ComponentName = $ComponentName
 
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall") <>                                         }
     
                                            If($OptimizationTable.Count -gt 0)
                                                {                                           {
                                                        Line 10 ": " $FSLogixDeploymentSettingsInstallerFileName                                                   $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns DisplayName, ComponentName `
                                                    -Headers "Display name", "Component" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 200;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                                }                                           }
                                                Line 3 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()    
                                                Line 3 "Settings"    
                                                Line 4 "Location type`t`t`t`t`t: " $FSLogixLocationType    
                                                                                   }
                                                $cnt = -1    
                                                ForEach($item in $FSLogixLocationOfProfileDisks)                                   WriteWordLine 5 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
                                                {                                   {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Services Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable services:"; Value = ""; }) > $Null
                                                        $cnt++    
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                                                                          
                                                        If($cnt -eq 0)                                           ForEach($item in $RDSTemplate.Optimization.WindowsServices.WindowsServicesList)
                                            {
                                                            If($Null -eq $item.DisplayName)
 
                                                                Line 4 "Location of profile disks`t`t`t: " $item <>                                                                 $DisplayName = ""
 
                                                                Line 10 "  " $item <>                                                                 $DisplayName = $item.DisplayName
 
                                                } <>                                                         If($Null -eq $item.ServiceName)
                                                Line 4 "Profile disk format`t`t`t`t: " $FSLogixProfileDiskFormat    
                                                Line 4 "Allocation type`t`t`t`t`t: " $FSLogixAllocationType    
                                                Line 4 "Default size`t`t`t`t`t: " "$FSLogixDefaultSize GB"    
                                                Line 3 "Additional settings"    
                                                Line 4 "Users and Groups"    
                                                    
                                                If($FSLogixSettingsUserInclusionList.Count -eq 0)    
                                                {                                                           {
                                                        Line 5 "User Inclusion List`t`t`t: " "None"                                                                   $Service = ""
                                                }                                                           }
                                                Else                                                           Else
                                                {                                                           {
                                                        $cnt = -1                                                                   $Service = $item.ServiceName
                                                        ForEach($item in $FSLogixSettingsUserInclusionList)    
                                                        {                                                           }
                                                                $cnt++                                                           If($Null -eq $item.Aliases)
                                                                    
                                                                If($cnt -eq 0)    
                                                                {                                                           {
                                                                        Line 5 "User Inclusion List`t`t`t: " "User: $($item.Account)  Type: $($item.Type)"                                                                   $Aliases = ""
                                                                }                                                           }
                                                                Else                                                           Else
                                                                {                                                           {
                                                                        Line 10 "  " "User: $($item.Account)  Type: $($item.Type)"                                                                   $Aliases = $item.Aliases
                                                                }                                                           }
                                                    $OptimizationTable += @{
                                                            DisplayName = $DisplayName
                                                            Service     = $Service
                                                            Aliases     = $Aliases
                                                        }                                                   }
                                                }                                           }
 
                                                If($FSLogixSettingsUserExclusionList.Count -eq 0) <>                                         If($OptimizationTable.Count -gt 0)
                                                {                                           {
                                                        Line 5 "User Exclusion List`t`t`t: " "None"                                                   $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns DisplayName, Service, Aliases `
                                                    -Headers "Display name", "Service", "Aliases" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 100;
                                                    $Table.Columns.Item(3).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                                }                                           }
                                    }
                                    
                                    WriteWordLine 5 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                    If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Scheduled Tasks Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable tasks:"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            ForEach($item in $RDSTemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                            {
                                                            If($Null -eq $item.Task)
                                                            {
                                                                    $Task = ""
                                                            }
                                                Else                                                           Else
                                                {                                                           {
                                                                    $Task = $item.Task
                                                        $cnt = -1                                                           }
                                                        ForEach($item in $FSLogixSettingsUserExclusionList)                                                           If($Null -eq $item.Type)
 
  <>                                                                 $Type = ""
                                                                $cnt++                                                           }
                                                            Else
                                                                                                                           {
                                                                    $Type = $item.Type.ToString()
                                                            }
                                                                If($cnt -eq 0)                                                           If($Null -eq $item.Location)
                                                                {                                                           {
                                                                        Line 5 "User Exclusion List`t`t`t: " "User: $($item.Account)  Type: $($item.Type)"                                                                   $Location = ""
                                                                }                                                           }
                                                                Else                                                           Else
                                                                {                                                           {
                                                                        Line 10 "  " "User: $($item.Account)  Type: $($item.Type)"                                                                   $Location = $item.Location
                                                                }                                                           }
                                                    $OptimizationTable += @{
                                                            Task     = $Task
                                                            Type     = $Type
                                                            Location = $Location
                                                        }                                                   }
                                                }                                           }
                                                Line 4 "Folders"    
                                                Line 5 "Customize profile folders`t`t: " $FSLogixSettingsCustomizeProfileFolders.ToString()                                           If($OptimizationTable.Count -gt 0)
                                                If($FSLogixSettingsCustomizeProfileFolders)    
                                                {                                           {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Task, Type, Location `
                                                    -Headers "Task", "Type", "Location" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                        If($ExcludedCommonFolders.Count -gt 0)                                                   $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 250;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                                        {                                   {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Advanced Options"; Value = ""; }) > $Null
                                                                $cnt = -1    
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                                ForEach($item in $ExcludedCommonFolders)                                           FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Disable Hibernate"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Telemetry collection"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable System Restore"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable error reporting to send additional data"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Tiles"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Cortana digital assistant"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Turn off Microsoft consumer experience"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Do not show Windows tips"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Remove Common program groups from the Start Menu"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Partial Start Menu layout"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString()
                                                    Value   = $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                                                {                                           {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled, Value `
                                                    -Headers "Setting", "Enabled", "Value" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
                                                                        $cnt++    
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 275;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 175;
                                                                                                                          
                                                                        If($cnt -eq 0)                                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTNetworkPerformanceEnabled -eq "True")
                                                                        {                                   {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Network Performance Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "FileInfoCacheEntriesMax"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString()
                                                    Value   = $RDSTemplate.Optimization.NetworkPerformance.FileInfoCache
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "DirectoryCacheEntriesMax"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString()
                                                    Value   = $RDSTemplate.Optimization.NetworkPerformance.DirCacheMax
                                            }
     
                                            $OptimizationTable += @{
                                                                                Line 6 "Exclude Common Folders`t`t: " $item                                                   Setting = "FileNotFoundCacheEntriesMax"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString()
                                                    Value   = $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCache
                                                                        }                                           }
                                                                        Else    
                                            $OptimizationTable += @{
                                                    Setting = "DormantFileLimit"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString()
                                                    Value   = $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimit
                                                                        {                                           }
                                                                                Line 10 "  " $item    
                                            $OptimizationTable += @{
                                                    Setting = "Disable TCP/IP Task Offload"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableTCP.ToString()
                                                    Value   = ""
                                                                        }                                           }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable IPv6 Components"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString()
                                                    Value   = ""
                                                                }                                           }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable IPv6 to IPv4"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString()
                                                    Value   = ""
                                                        }                                           }
                                                        Else    
                                            $OptimizationTable += @{
                                                    Setting = "Disables isatap for IPv6"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString()
                                                    Value   = ""
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                                        {                                           {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled, Value `
                                                    -Headers "Setting", "Enabled", "Value" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 150;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                                Line 6 "Exclude Common Folders`t`t: None"                                                   FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                                        }                                           }
                                                }                                   }
 
  <>                                 WriteWordLine 5 0 "Registry: " $OPTRegistryEnabled
                                    If($OPTRegistryEnabled -eq "True")
                                    {
                                                If($FSLogixSettingsFolderInclusionList.Count -eq 0)                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Registry Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
     
                                            ForEach($item in $RDSTemplate.Optimization.Registry.RegistryList)
                                                {                                           {
                                                        Line 5 "Folder Inclusion List`t`t`t: " "None"                                                   $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Data"; Value = $item.DWORDValue; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                }                                           }
                                                Else    
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 125;
                                            $Table.Columns.Item(2).Width = 375;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    
                                    WriteWordLine 5 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                                {                                   {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Visual Effects Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Animate controls and elements inside windows"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Animate windows when minimizing and maximizing"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Animations in the taskbar"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.AnimateTaskbar.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Enable Peek"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.EnablePeek.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                        Line 5 "Folder Inclusion List"                                                   Setting = "Fade or slide menus into view"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.FadeSlideMenus.ToString()
                                            }
                                                        $cnt = -1    
                                            $OptimizationTable += @{
                                                    Setting = "Fade or slide Tooltips into view"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Fade out menu items after clicking"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Save taskbar thumbnail previews"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show shadows under mouse pointer"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show shadows under windows"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                        ForEach($item in $FSLogixSettingsFolderInclusionList)                                                   Setting = "Show thumbnails instead of icons"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show translucent selection rectangle"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show window contents while dragging"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Slide open combo boxes"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Smooth edges of screen fonts"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Smooth-scroll list boxes"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Use drop shadows for icon labels on the desktop"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.DropShadowsIcon.ToString()
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                                        {                                           {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled `
                                                    -Headers "Setting", "Enabled" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
                                                                $cnt++    
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 250;
                                                    $Table.Columns.Item(2).Width = 50;
                                                                                                                  
                                                                If($cnt -eq 0)                                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                                                {                                   {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Disk Cleanup Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                                                        Line 6 "Folder`t`t`t`t: " $item                                           WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Clean up redundant system files"
                                                    Enabled = $RDSTemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString()
                                                                }                                           }
                                                                Else    
                                            $OptimizationTable += @{
                                                    Setting = "Clean up the WinSxS Folder"
                                                    Enabled = $RDSTemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Clean up temporary files and logs"
                                                    Enabled = $RDSTemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Remove OneDrive"
                                                    Enabled = $RDSTemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Delete users' profiles"
                                                    Enabled = $RDSTemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString()
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                                                {                                           {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled `
                                                    -Headers "Setting", "Enabled" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 175;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                                        Line 10 "  " $item                                                   WriteWordLine 0 0 ""
                                                                }                                           }
                                                        }                                   }
     
                                    WriteWordLine 5 0 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Custom Script"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Command"; Value = $RDSTemplate.Optimization.CustomScript.Command; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Arguments"; Value = $RDSTemplate.Optimization.CustomScript.Arguments; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Initial directory"; Value = $RDSTemplate.Optimization.CustomScript.InitDir; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Username"; Value = $RDSTemplate.Optimization.CustomScript.User; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 100;
                                            $Table.Columns.Item(2).Width = 200;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                                }                                   }
                            }
                                                If($FSLogixSettingsFolderExclusionList.Count -eq 0)                           If($Text)
                                                {                           {
                                                        Line 5 "Folder Exclusion List`t`t`t: " "None"                                   Line 3 "Inherit default settings`t: " $RDSTemplate.InheritDefaultOptimizationSettings.ToString()
                                    Line 3 "Enable optimization`t`t: " $OPTEnableOptimization
                                    Line 3 "Optimization type`t`t: " $OPTOptimizationType
                                    Line 3 "Category"
                                    
                                    Line 4 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                    If($OPTWindowsDefenderATPEnabled -eq "True")
                                    {
                                            Line 5 "Windows Defender ATP Optimizations"
                                            If($RDSTemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                            {
                                                    Line 6 "Turn off Windows Defender ATP (I use my own ATP solution)"
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                    Line 6 "Turn on Windows Defender ATP and set process and folder exclusions"
                                                    Line 6 "Disable real-time protection: " $RDSTemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString()
                                                    Line 0 ""
                                                        Line 5 "Folder Exclusion List"                                                   Line 6 "Exclude files and folders:"
                                                        $cnt = -1    
                                                        ForEach($item in $FSLogixSettingsFolderExclusionList)                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                        {                                                   {
                                                                $cnt++                                                           Line 7 $item
                                                                    
                                                                Switch($item.ExcludeFolderCopy)    
                                                                {    
                                                                        "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}    
                                                                        "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}    
                                                                        "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}    
                                                                        "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}    
                                                                        Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}    
                                                                }                                                   }
                                                                    
                                                                If($cnt -eq 0)                                                   Line 6 "Exclude processes:"
                                                    ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                                {                                                   {
                                                                        Line 6 "Folder`t`t`t`t: " "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"                                                           Line 7 $item
                                                                }                                                   }
                                                                Else                                                  
                                                    Line 6 "Exclude extensions:"
                                                    ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                                {                                                   {
                                                                        Line 10 "  " "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"                                                           Line 7 $item
                                                                }                                                   }
                                                        }                                           }
                                            
                                            Line 0 ""
                                                }                                   }
                                                                                  
                                    Line 4 "Windows Components: " $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
                                    {
                                            Line 5 "Windows Components Optimizations"
                                            Line 6 "Disable (remove) components:"
                                                Line 4 "Advanced"                                           Line 0 ""
                                                Line 5 "FSLogix Setting                                      Value"                                           Line 6 "Display name                                        Component                                         "
                                                Line 5 "======================================================================================"                                           Line 6 "======================================================================================================"
                                                #      "Swap SID and username in profile directory names     Redirect TEMP, TMP, and INetCache"                                           #               12345678901234567890123456789012345678901234567890SS12345678901234567890123456789012345678901234567890
                                                Line 6 "Access network as computer object                    $($FSLogixAS_AccessNetworkAsComputerObject)"    
                                                Line 6 "Custom SDDL for profile directory                    $($FSLogixAS_ProfileDirSDDL)"    
                                                Line 6 "Delay between locked VHD(X) retries                  $($FSLogixAS_LockedRetryInterval)"    
                                                Line 6 "Delete local profile when loading from VHD           $($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)"    
                                                Line 6 "Diff disk parent folder path                         $($FSLogixAS_DiffDiskParentFolderPath)"    
                                                Line 6 "Do not create a folder for new profiles              $($FSLogixAS_NoProfileContainingFolder)"    
                                                Line 6 "Enable Cached mode for Outlook                       $($FSLogixAS_OutlookCachedMode)"    
                                                Line 6 "Keep local profiles                                  $($FSLogixAS_KeepLocalDir)"    
                                                Line 6 "Naming pattern for new VHD(X) files                  $($FSLogixAS_VHDNamePattern)"    
                                                Line 6 "Number of locked VHD(X) retries                      $($FSLogixAS_LockedRetryCount)"    
                                                Line 6 "Prevent logons with failures                         $($FSLogixAS_PreventLoginWithFailure)"    
                                                Line 6 "Prevent logons with temp profiles                    $($FSLogixAS_PreventLoginWithTempProfile)"    
                                                Line 6 "Profile folder naming pattern                        $($FSLogixAS_SIDDirNameMatch)"    
                                                Line 6 "Profile type                                         $($FSLogixAS_ProfileType)"    
                                                Line 6 "Profile VHD(X) file matching pattern                 $($FSLogixAS_VHDNameMatch)"    
                                                Line 6 "Re-attach interval                                   $($FSLogixAS_ReAttachIntervalSeconds)"    
                                                Line 6 "Re-attach retry limit                                $($FSLogixAS_ReAttachRetryCount)"    
                                                Line 6 "Remove duplicate OST files on logoff                 $($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)"    
                                                Line 6 "SDDL used when attaching the VHD                     $($FSLogixAS_AttachVHDSDDL)"    
                                                Line 6 "Search roaming feature mode                          $($FSLogixAS_RoamSearch)"    
                                                Line 6 "Swap SID and username in profile directory names     $($FSLogixAS_FlipFlopProfileDirectoryName)"    
                                                Line 6 "Temporary folders redirection mode                   $($FSLogixAS_SetTempToLocalPath)"    
                                                Line 6 "Use SDDL on creation of SID containing folder        $($FSLogixAS_SIDDirSDDL)"    
                                                Line 6 "User-to-Profile matching pattern                     $($FSLogixAS_SIDDirNamePattern)"                                           #               Printing-XPSServices-Features                       SMB 1.0/CIFS File sharing support component
                                                Line 6 "VHDX sector size                                     $($FSLogixAS_VHDXSectorSize)"                                           ForEach($item in $RDSTemplate.Optimization.WindowsComponents.WindowsComponentsList)
                                                Line 6 "Volume wait time                                     $($FSLogixAS_VolumeWaitTimeMS)"                                           {
                                                    Line 6 ( "{0,-50}  {1,-50}" -f $item.DisplayName, $item.ComponentName)
 
  +-  
 
                                If($HTML) <>                                
                                    Line 4 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
 
                                        $rowdata = @() <>                                         Line 5 "Windows Services Optimizations"
                                        $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefUserProfileSettings.ToString(),$htmlwhite)                                           Line 6 "Disable services:"
                                        $rowdata += @(,("Technology",($Script:htmlsb),$TemplateTechnology,$htmlwhite))    
                                            Line 0 ""
                                        If($TemplateTechnology -eq "Do not manage by RAS")                                           Line 6 "Display name                                        Service                         Aliases             "
                                            Line 6 "========================================================================================================"
                                            #               12345678901234567890123456789012345678901234567890SS123456789012345678901234567890SS12345678901234567890
                                            #               Windows Media Player Network Sharing Service        TabletInputService              Superfecth
                                            ForEach($item in $RDSTemplate.Optimization.WindowsServices.WindowsServicesList)
 
                                                #do nothing <>                                                 Line 6 ( "{0,-50}  {1,-30}  {2,-20}" -f $item.DisplayName, $item.ServiceName, $item.Aliases)
 
  <>                                         Line 0 ""
                                    }
                                    
                                    Line 4 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                        ElseIf($TemplateTechnology -eq "FSLogix")                                   If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                    {
                                            Line 5 "Windows Scheduled Tasks Optimizations"
                                            Line 6 "Disable tasks:"
                                            Line 0 ""
                                            Line 6 "Task                                                Type    Location                                          "
                                            Line 6 "=============================================================================================================="
                                            #               12345678901234567890123456789012345678901234567890SS123456SS12345678901234567890123456789012345678901234567890
                                            #               MNO Metadata Parser                                 Folder  \Microsoft\Windows\Mobile Broadband Accounts\
                                            ForEach($item in $RDSTemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
 
                                                $rowdata += @(,("Deployment method",($Script:htmlsb),$FSLogixDeploymentSettingsDeploymentMethod,$htmlwhite)) <>                                                 Line 6 ( "{0,-50}  {1,-6}  {2,-50}" -f $item.Task, $item.Type.ToString(), $item.Location)
                                                If($FSLogixDeploymentSettings.InstallType -eq "Online")                                           }
                                            Line 0 ""
                                    }
     
                                    Line 4 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                                {                                   {
                                            Line 5 "Windows Advanced Options"
                                            Line 0 ""
                                            Line 6 "Setting                                           Enabled  Value                                             "
                                            Line 6 "============================================================================================================="
                                            #               123456789012345678901234567890123456789012345678SS1234567SS12345678901234567890123456789012345678901234567890
                                            #               Remove Common program groups from the start menu  False    SomeConfigFile.xml
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Hibernate", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Telemetry collection", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable System Restore", `
                                                        $rowdata += @(,("URL",($Script:htmlsb),$FSLogixDeploymentSettingsInstallOnlineURL,$htmlwhite))                                           $RDSTemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable error reporting to send additional data", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Tiles", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Cortana digital assistant", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Turn off Microsoft consumer experience", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Do not show Windows tips", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Remove Common program groups from the Start Menu", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Partial Start Menu layout", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(), `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent)
                                            
                                            Line 0 ""
                                                }                                   }
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")    
                                    Line 4 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTNetworkPerformanceEnabled -eq "True")
                                                {                                   {
                                            Line 5 "Network Performance Optimizations"
                                            Line 0 ""
                                            Line 6 "Setting                      Enabled  Value"
                                            Line 6 "==========================================="
                                            #               123456789012345678901234567SS1234567SS12345
                                            #               FileNotFoundCacheEntriesMax  False    32768
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "FileInfoCacheEntriesMax", `
                                            $RDSTemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(), `
                                            $RDSTemplate.Optimization.NetworkPerformance.FileInfoCache)
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "DirectoryCacheEntriesMax", `
                                            $RDSTemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(), `
                                            $RDSTemplate.Optimization.NetworkPerformance.DirCacheMax)
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "FileNotFoundCacheEntriesMax", `
                                            $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(), `
                                            $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCache)
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "DormantFileLimit", `
                                                        $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsNetworkDrivePath,$htmlwhite))                                           $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(), `
                                            $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimit)
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable TCP/IP Task Offload", `
                                            $RDSTemplate.Optimization.NetworkPerformance.DisableTCP.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable IPv6 Components", `
                                            $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable IPv6 to IPv4", `
                                            $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disables isatap for IPv6", `
                                            $RDSTemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(), `
                                            "")
                                            
                                            Line 0 ""
                                                }                                   }
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")    
                                    Line 4 "Registry: " $OPTRegistryEnabled
                                    If($OPTRegistryEnabled -eq "True")
                                                {                                   {
                                            Line 5 "Registry Optimizations"
                                            Line 0 ""
                                            #               123456789012345678901234567SS1234567SS12345
                                            #               FileNotFoundCacheEntriesMax  False    32768
                                            Line 6 "Registry                                  Action  Value                 Type           Data                  Path                                                        "
                                            Line 6 "========================================================================================================================================================================="
                                            #               1234567890123456789012345678901234567890SS123456SS12345678901234567890SS1234567890123SS12345678901234567890SS123456789012345678901234567890123456789012345678901234567890
                                            #               Increase service startup timeouts         Modify  99999999999999999999  REG_EXPAND_SZ  99999999999999999999  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Disk
                                                        $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsInstallerFileName,$htmlwhite))                                           ForEach($item in $RDSTemplate.Optimization.Registry.RegistryList)
                                            {
                                                    Line 6 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `
                                                    $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType, $item.DWORDValue, "$($item.HiveType)\$($item.Path)")
                                                }                                           }
                                                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))                                           Line 0 ""
                                                $rowdata += @(,("Settings",($Script:htmlsb),"",$htmlwhite))                                   }
                                                $rowdata += @(,("     Location type",($Script:htmlsb),$FSLogixLocationType,$htmlwhite))    
                                    Line 4 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                    {
                                            Line 5 "Visual Effects Optimizations"
                                            Line 0 ""
                                                                                          
                                                $cnt = -1                                           Switch ($RDSTemplate.Optimization.VisualEffects.VisualEffectsTypes)
                                                ForEach($item in $FSLogixLocationOfProfileDisks)    
                                                {                                           {
                                                    "LetWindowsChooseWhatsBest"     {$VisualEffectsType = "Let Windows choose what's best"; Break}
                                                    "AdjustForBestAppearnce"        {$VisualEffectsType = "Adjust for best appearance"; Break} #misspelled in the PoSH output and the docs
                                                    "AdjustForBestPerformance"      {$VisualEffectsType = "Adjust for best performance"; Break}
                                                    "Custom"                                        {$VisualEffectsType = "Custom"; Break}
                                                    Default                                         {$VisualEffectsType = "Unable to determine Visual Effects Optimization type: $($RDSTemplate.Optimization.VisualEffects.VisualEffectsTypes)"; Break}
                                                        $cnt++                                           }
                                            Line 6 $VisualEffectsType
                                            Line 0 ""
                                            Line 6 "Setting                                             Enabled"
                                            Line 6 "==========================================================="
                                            #               12345678901234567890123456789012345678901234567890SS1234567
                                            #               Use drop shadows for icon labels on the desktop     False  
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Animate controls and elements inside windows", `
                                            $RDSTemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString())
                                                                                                  
                                                        If($cnt -eq 0)                                           Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Animate windows when minimizing and maximizing", `
                                            $RDSTemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Animations in the taskbar", `
                                            $RDSTemplate.Optimization.VisualEffects.AnimateTaskbar.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Enable Peek", `
                                            $RDSTemplate.Optimization.VisualEffects.EnablePeek.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Fade or slide menus into view", `
                                            $RDSTemplate.Optimization.VisualEffects.FadeSlideMenus.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Fade or slide Tooltips into view", `
                                            $RDSTemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Fade out menu items after clicking", `
                                            $RDSTemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Save taskbar thumbnail previews", `
                                            $RDSTemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Show shadows under mouse pointer", `
                                            $RDSTemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Show shadows under windows", `
                                            $RDSTemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Show thumbnails instead of icons", `
                                            $RDSTemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Show translucent selection rectangle", `
                                            $RDSTemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Show window contents while dragging", `
                                            $RDSTemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Slide open combo boxes", `
                                            $RDSTemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Smooth edges of screen fonts", `
                                            $RDSTemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Smooth-scroll list boxes", `
                                            $RDSTemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Use drop shadows for icon labels on the desktop", `
                                            $RDSTemplate.Optimization.VisualEffects.DropShadowsIcon.ToString())
                                            
                                            Line 0 ""
                                    }
     
                                    Line 4 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                                        {                                   {
                                                                $rowdata += @(,("     Location of profile disks",($Script:htmlsb),$item,$htmlwhite))                                           Line 5 "Disk Cleanup Optimizations"
                                            Line 0 ""
                                            
                                            Line 6 "Setting                            Enabled"
                                            Line 6 "=========================================="
                                            #               123456789012345678901234567890123SS1234567
                                            #               Clean up temporary files and logs  False  
                                            Line 6 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up redundant system files", `
                                            $RDSTemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString())
                                            
                                            Line 6 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up the WinSxS Folder", `
                                            $RDSTemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString())
                                            
                                            Line 6 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up temporary files and logs", `
                                            $RDSTemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString())
                                            
                                            Line 6 ( "{0,-33}  {1,-7}" -f `
                                            "Remove OneDrive", `
                                            $RDSTemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString())
                                            
                                            Line 6 ( "{0,-33}  {1,-7}" -f `
                                            "Delete users' profiles", `
                                            $RDSTemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString())
                                            
                                            Line 0 ""
                                                        }                                   }
                                                        Else    
                                    Line 4 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled  -eq "True")
                                                        {                                   {
                                                                $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))                                           Line 5 "Custom Script"
                                            Line 0 ""
                                            
                                            Line 6 "Command`t`t : " $RDSTemplate.Optimization.CustomScript.Command
                                            Line 6 "Arguments`t : " $RDSTemplate.Optimization.CustomScript.Arguments
                                            Line 6 "Initial directory: " $RDSTemplate.Optimization.CustomScript.InitDir
                                            Line 6 "Username`t : " $RDSTemplate.Optimization.CustomScript.User
                                            Line 0 ""
                                                        }                                   }
                                    Line 0 ""
                                                }                           }
                            If($HTML)
                            {
                                    $rowdata = @()
                                                $rowdata += @(,("     Profile disk format",($Script:htmlsb),$FSLogixProfileDiskFormat,$htmlwhite))                                   $columnHeaders = @("Inherit default settings:",($Script:htmlsb),$RDSTemplate.InheritDefaultOptimizationSettings.ToString(),$htmlwhite)
                                                $rowdata += @(,("     Allocation type",($Script:htmlsb),$FSLogixAllocationType,$htmlwhite))                                   $rowdata += @(,("Enable optimization:",($Script:htmlsb), $OPTEnableOptimization,$htmlwhite))
                                                $rowdata += @(,("     Default size",($Script:htmlsb),"$FSLogixDefaultSize GB",$htmlwhite))    
                                                $rowdata += @(,("Additional settings",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Optimization type:",($Script:htmlsb), $OPTOptimizationType,$htmlwhite))
     
                                    $msg = "Optimization"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 4 0 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                    If($OPTWindowsDefenderATPEnabled -eq "True")
                                    {
                                            $rowdata = @()
                                                $rowdata += @(,("     Users and Groups",($Script:htmlsb),"",$htmlwhite))                                           $columnHeaders = @("Windows Defender ATP Optimizations",($Script:htmlsb),"",$htmlwhite)
                                                    
                                                If($FSLogixSettingsUserInclusionList.Count -eq 0)                                           If($RDSTemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                                {                                           {
                                                        $rowdata += @(,("          User Inclusion List",($Script:htmlsb),"None",$htmlwhite))                                                   $rowdata += @(,("     Turn off Windows Defender ATP (I use my own ATP solution)",($Script:htmlsb), "",$htmlwhite))
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                    $rowdata += @(,("     Turn on Windows Defender ATP and set process and folder exclusions",($Script:htmlsb), "",$htmlwhite))
                                                    $rowdata += @(,("     Disable real-time protection",($Script:htmlsb), $RDSTemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(),$htmlwhite))
                                                    $rowdata += @(,("",($Script:htmlsb), "",$htmlwhite))
                                                    
                                                        $cnt = -1                                                   $cnt = -1
                                                        ForEach($item in $FSLogixSettingsUserInclusionList)                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                        {                                                   {
                                                                $cnt++                                                           $cnt++
                                                                    
                                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                                {                                                           {
                                                                        $rowdata += @(,("          User Inclusion List",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))                                                                   $rowdata += @(,("     Exclude files and folders",($Script:htmlsb), $item,$htmlwhite))
                                                                        $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))    
                                                                }                                                           }
                                                                Else                                                           Else
                                                                {                                                           {
                                                                        $rowdata += @(,("",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                }    
 
                                                If($FSLogixSettingsUserExclusionList.Count -eq 0) <>  
                                                {    
                                                        $rowdata += @(,("          User Exclusion List",($Script:htmlsb),"None",$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $cnt = -1                                                   $cnt = -1
                                                        ForEach($item in $FSLogixSettingsUserExclusionList)                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                        {                                                   {
                                                                $cnt++                                                           $cnt++
                                                                    
                                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                                {                                                           {
                                                                        $rowdata += @(,("          User Exclusion List",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))                                                                   $rowdata += @(,("     Exclude processes",($Script:htmlsb), $item,$htmlwhite))
                                                                        $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))    
                                                                }                                                           }
                                                                Else                                                           Else
                                                                {                                                           {
                                                                        $rowdata += @(,("",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                }    
 
                                                $rowdata += @(,("     Folders",($Script:htmlsb),"",$htmlwhite)) <>  
                                                $rowdata += @(,("          Customize profile folders",($Script:htmlsb),$FSLogixSettingsCustomizeProfileFolders.ToString(),$htmlwhite))    
                                                If($FSLogixSettingsCustomizeProfileFolders)    
                                                {                                                  
                                                        If($ExcludedCommonFolders.Count -gt 0)    
                                                        {    
                                                                $cnt = -1                                                   $cnt = -1
                                                                ForEach($item in $ExcludedCommonFolders)                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                                {                                                   {
                                                                        $cnt++                                                           $cnt++
                                                                            
                                                                        If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                                        {                                                           {
                                                                                $rowdata += @(,("               Exclude Common Folders",($Script:htmlsb),$item,$htmlwhite))                                                                   $rowdata += @(,("     Exclude extensions",($Script:htmlsb), $item,$htmlwhite))
                                                                        }                                                           }
                                                                        Else                                                           Else
                                                                        {                                                           {
                                                                                $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                        }                                                           }
                                                                }                                                   }
                                                        }                                           }
                                                        Else    
     
                                            $msg = ""
                                            $columnWidths = @("300","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows Components: " $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
                                                        {                                   {
                                                                $rowdata += @(,("               Exclude Common Folders",($Script:htmlsb),"None",$htmlwhite))                                           WriteHTMLLine 0 0 "Windows Components Optimizations"
     
                                            $rowdata = @()
     
                                            ForEach($item in $RDSTemplate.Optimization.WindowsComponents.WindowsComponentsList)
                                                        }                                           {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.ComponentName,$htmlwhite)
                                                    )
                                                }                                           }
 
                                                If($FSLogixSettingsFolderInclusionList.Count -eq 0) <>                                         $columnHeaders = @(
                                                    "Display Name",($Script:htmlsb),
                                                    "Component",($Script:htmlsb)
                                                {                                           )
                                                        $rowdata += @(,("          Folder Inclusion List",($Script:htmlsb),"None",$htmlwhite))    
                                            $msg = "Disable (remove) components:"
                                            $columnWidths = @("200","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                }                                   }
                                                Else    
                                    WriteHTMLLine 4 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
                                                {                                   {
                                                        $rowdata += @(,(         Folder Inclusion List",($Script:htmlsb),"",$htmlwhite))                                           WriteHTMLLine 0 0 "Windows Services Optimizations"
                                                        $cnt = -1    
                                            $rowdata = @()
     
                                                        ForEach($item in $FSLogixSettingsFolderInclusionList)                                           ForEach($item in $RDSTemplate.Optimization.WindowsServices.WindowsServicesList)
                                                        {                                           {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.ServiceName,$htmlwhite,
                                                            $item.Aliases,$htmlwhite)
                                                    )
                                            }
                                                                $cnt++    
                                            $columnHeaders = @(
                                                    "Display Name",($Script:htmlsb),
                                                    "Service",($Script:htmlsb),
                                                    "Aliases",($Script:htmlsb)
                                            )
                                                                    
                                                                If($cnt -eq 0)                                           $msg = "Disable services:"
                                            $columnWidths = @("200","100","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled
                                    If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                                                {                                   {
                                                                        $rowdata += @(,("               Folder",($Script:htmlsb),"$item",$htmlwhite))                                           WriteHTMLLine 0 0 "Windows Scheduled Tasks Optimizations"
                                                                }    
                                            $rowdata = @()
                                                                Else    
                                            ForEach($item in $RDSTemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                                                {                                           {
                                                                        $rowdata += @(,("",($Script:htmlsb),"$item",$htmlwhite))                                                   $rowdata += @(,(
                                                            $item.Task,$htmlwhite,
                                                            $item.Type.Tostring(),$htmlwhite,
                                                            $item.Location,$htmlwhite)
                                                    )
                                                                }                                           }
     
                                            $columnHeaders = @(
                                                    "Task",($Script:htmlsb),
                                                    "Type",($Script:htmlsb),
                                                    "Location",($Script:htmlsb)
                                            )
     
                                            $msg = "Disable tasks:"
                                            $columnWidths = @("200","50","250")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                        }                                   }
     
                                    WriteHTMLLine 4 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Windows Advanced Options"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Disable Hibernate",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Telemetry collection",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable System Restore",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable error reporting to send additional data",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Tiles",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Cortana digital assistant",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Turn off Microsoft consumer experience",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Do not show Windows tips",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Remove Common program groups from the Start Menu",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Partial Start Menu layout",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(),$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent,$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb),
                                                    "Value",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("300","50","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                }                                   }
 
                                                If($FSLogixSettingsFolderExclusionList.Count -eq 0) <>                                 WriteHTMLLine 4 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                                {                                   {
                                            WriteHTMLLine 0 0 "Network Performance Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "FileInfoCacheEntriesMax",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(),$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.FileInfoCache,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "DirectoryCacheEntriesMax",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(),$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DirCacheMax,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                        $rowdata += @(,("          Folder Exclusion List",($Script:htmlsb),"None",$htmlwhite))                                                   "FileNotFoundCacheEntriesMax",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(),$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCache,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "DormantFileLimit",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(),$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimit,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable TCP/IP Task Offload",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DisableTCP.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable IPv6 Components",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable IPv6 to IPv4",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disables isatap for IPv6",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb),
                                                    "Value",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("170","50","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                }                                   }
                                                Else    
                                    WriteHTMLLine 4 0 "Registry: " $OPTRegistryEnabled       
                                    If($OPTRegistryEnabled -eq "True")
                                                {                                   {
                                                        $rowdata += @(,("          Folder Exclusion List",($Script:htmlsb),"",$htmlwhite))                                           WriteHTMLLine 0 0 "Registry Optimizations"
                                                        $cnt = -1    
                                            $rowdata = @()
     
                                                        ForEach($item in $FSLogixSettingsFolderExclusionList)                                           ForEach($item in $RDSTemplate.Optimization.Registry.RegistryList)
                                                        {                                           {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.Action,$htmlwhite,
                                                            $item.RegistryName,$htmlwhite,
                                                            $item.RegType,$htmlwhite,
                                                            $item.DWORDValue,$htmlwhite,
                                                            "$($item.HiveType)\$($item.Path)",$htmlwhite)
                                                                $cnt++                                                   )
                                            }
                                                                    
                                            $columnHeaders = @(
                                                    "Registry",($Script:htmlsb),
                                                    "Action",($Script:htmlsb),
                                                                Switch($item.ExcludeFolderCopy)                                                   "Value",($Script:htmlsb),
                                                    "Type",($Script:htmlsb),
                                                    "Data",($Script:htmlsb),
                                                    "Path",($Script:htmlsb)
                                                                {                                           )
                                                                        "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}    
                                                                        "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}                                           $msg = ""
                                                                        "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}                                           $columnWidths = @("200","50","100","100","100","200")
                                                                        "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                                        Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}                                           WriteHTMLLine 0 0 ""
                                                                }                                   }
                                                                    
                                                                If($cnt -eq 0)                                   WriteHTMLLine 4 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                                                {                                   {
                                                                        $rowdata += @(,("               Folder",($Script:htmlsb),"$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack",$htmlwhite))                                           WriteHTMLLine 0 0 "Visual Effects Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Animate controls and elements inside windows",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Animate windows when minimizing and maximizing",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Animations in the taskbar",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.AnimateTaskbar.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Enable Peek",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.EnablePeek.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade or slide menus into view",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.FadeSlideMenus.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade or slide Tooltips into view",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade out menu items after clicking",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Save taskbar thumbnail previews",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show shadows under mouse pointer",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show shadows under windows",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show thumbnails instead of icons",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show translucent selection rectangle",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show window contents while dragging",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Slide open combo boxes",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Smooth edges of screen fonts",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Smooth-scroll list boxes",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Use drop shadows for icon labels on the desktop",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.DropShadowsIcon.ToString(),$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("275","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                                }                                   }
                                                                Else    
                                    WriteHTMLLine 4 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                                                {                                   {
                                                                        $rowdata += @(,("",($Script:htmlsb),"$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack",$htmlwhite))                                           WriteHTMLLine 0 0 "Disk Cleanup Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Clean up redundant system files",$htmlwhite,
                                                    $RDSTemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString(),$htmlwhite)
                                                                }                                           )
     
                                            $rowdata += @(,(
                                                    "Clean up the WinSxS Folder",$htmlwhite,
                                                    $RDSTemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString(),$htmlwhite)
                                                        }                                           )
     
                                            $rowdata += @(,(
                                                    "Clean up temporary files and logs",$htmlwhite,
                                                    $RDSTemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Remove OneDrive",$htmlwhite,
                                                    $RDSTemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Delete users' profiles",$htmlwhite,
                                                    $RDSTemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString(),$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("200","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                }                                   }
 
                                                $rowdata += @(,("     Advanced",($Script:htmlsb),"",$htmlwhite)) <>                                 WriteHTMLLine 4 0 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled -eq "True")
                                    {
                                            $rowdata = @()
                                                $rowdata += @(,("          FSLogix Setting:",($Script:htmlsb),"Value:",$htmlwhite))                                           $columnHeaders = @("Custom Script",($Script:htmlsb),"",$htmlwhite)
                                                $rowdata += @(,("          Access network as computer object",($Script:htmlsb),"$($FSLogixAS_AccessNetworkAsComputerObject)",$htmlwhite))    
                                                $rowdata += @(,("          Custom SDDL for profile directory",($Script:htmlsb),"$($FSLogixAS_ProfileDirSDDL)",$htmlwhite))    
                                                $rowdata += @(,("          Delay between locked VHD(X) retries",($Script:htmlsb),"$($FSLogixAS_LockedRetryInterval)",$htmlwhite))    
                                                $rowdata += @(,("          Delete local profile when loading from VHD",($Script:htmlsb),"$($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)",$htmlwhite))    
                                                $rowdata += @(,("          Diff disk parent folder path",($Script:htmlsb),"$($FSLogixAS_DiffDiskParentFolderPath)",$htmlwhite))    
                                                $rowdata += @(,("          Do not create a folder for new profiles",($Script:htmlsb),"$($FSLogixAS_NoProfileContainingFolder)",$htmlwhite))    
                                                $rowdata += @(,("          Enable Cached mode for Outlook",($Script:htmlsb),"$($FSLogixAS_OutlookCachedMode)",$htmlwhite))    
                                                $rowdata += @(,("          Keep local profiles",($Script:htmlsb),"$($FSLogixAS_KeepLocalDir)",$htmlwhite))    
                                                $rowdata += @(,("          Naming pattern for new VHD(X) files",($Script:htmlsb),"$($FSLogixAS_VHDNamePattern)",$htmlwhite))    
                                                $rowdata += @(,("          Number of locked VHD(X) retries",($Script:htmlsb),"$($FSLogixAS_LockedRetryCount)",$htmlwhite))    
                                                $rowdata += @(,("          Prevent logons with failures",($Script:htmlsb),"$($FSLogixAS_PreventLoginWithFailure)",$htmlwhite))    
                                                $rowdata += @(,("          Prevent logons with temp profiles",($Script:htmlsb),"$($FSLogixAS_PreventLoginWithTempProfile)",$htmlwhite))    
                                                $rowdata += @(,("          Profile folder naming pattern",($Script:htmlsb),"$($FSLogixAS_SIDDirNameMatch)",$htmlwhite))                                           $rowdata += @(,("     Command",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.Command,$htmlwhite))
                                                $rowdata += @(,("          Profile type",($Script:htmlsb),"$($FSLogixAS_ProfileType)",$htmlwhite))    
                                                $rowdata += @(,("          Profile VHD(X) file matching pattern",($Script:htmlsb),"$($FSLogixAS_VHDNameMatch)",$htmlwhite))    
                                                $rowdata += @(,("          Re-attach interval",($Script:htmlsb),"$($FSLogixAS_ReAttachIntervalSeconds)",$htmlwhite))    
                                                $rowdata += @(,("          Re-attach retry limit",($Script:htmlsb),"$($FSLogixAS_ReAttachRetryCount)",$htmlwhite))                                           $rowdata += @(,("     Arguments",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.Arguments,$htmlwhite))
                                                $rowdata += @(,("          Remove duplicate OST files on logoff",($Script:htmlsb),"$($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)",$htmlwhite))    
                                                $rowdata += @(,("          SDDL used when attaching the VHD",($Script:htmlsb),"$($FSLogixAS_AttachVHDSDDL)",$htmlwhite))    
                                                $rowdata += @(,("          Search roaming feature mode",($Script:htmlsb),"$($FSLogixAS_RoamSearch)",$htmlwhite))    
                                                $rowdata += @(,("          Swap SID and username in profile directory names",($Script:htmlsb),"$($FSLogixAS_FlipFlopProfileDirectoryName)",$htmlwhite))                                           $rowdata += @(,("     Initial directory",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.InitDir,$htmlwhite))
                                                $rowdata += @(,("          Temporary folders redirection mode",($Script:htmlsb),"$($FSLogixAS_SetTempToLocalPath)",$htmlwhite))    
                                                $rowdata += @(,("          Use SDDL on creation of SID containing folder",($Script:htmlsb),"$($FSLogixAS_SIDDirSDDL)",$htmlwhite))    
                                                $rowdata += @(,("          User-to-Profile matching pattern",($Script:htmlsb),"$($FSLogixAS_SIDDirNamePattern)",$htmlwhite))                                           $rowdata += @(,("     Username",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.User,$htmlwhite))
                                                $rowdata += @(,("          VHDX sector size",($Script:htmlsb),"$($FSLogixAS_VHDXSectorSize)",$htmlwhite))    
                                                $rowdata += @(,("          Volume wait time",($Script:htmlsb),"$($FSLogixAS_VolumeWaitTimeMS)",$htmlwhite))    
                                        }    
 
                                        $msg = "User profile" <>                                         $msg = ""
                                        $columnWidths = @("350","325")                                           $columnWidths = @("125","200")
 
                                #> <>                         }
 
                                #License Keys <>                         #License Keys
                                                          
                                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                                {                           {
                                        WriteWordLine 4 0 "License Keys"                                   WriteWordLine 4 0 "License Keys"
                                }                           }
                                If($Text)                           If($Text)
                                {                           {
                                        Line 3 "License Keys"                                   Line 2 "License Keys"
                                }                           }
                                If($HTML)                           If($HTML)
                                {                           {
                                        #Nothing                                   #Nothing
                                }                           }
                                                          
                                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                                {                           {
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                                                          
                                        If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")                                   If($RDSTemplate.LicenseKeyType.ToString() -eq "KMS")
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "License key management type"; Value = "Key Management Service (KMS)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "License key management type"; Value = "Key Management Service (KMS)"; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "License key management type"; Value = "Multple Activation Key (MAK)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "License key management type"; Value = "Multple Activation Key (MAK)"; }) > $Null
                                                                                          
                                                $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null                                           $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $RDSTemplate.Id -EA 0 4>$Null
                                                                                          
                                                ForEach($Item in $LicenseKeys)                                           ForEach($Item in $LicenseKeys)
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = "License Key"; Value = $Item.LicenseKey; }) > $Null                                                   $ScriptInformation.Add(@{Data = "License Key"; Value = $Item.LicenseKey; }) > $Null
                                                        $ScriptInformation.Add(@{Data = "Key Limit"; Value = $Item.KeyLimit; }) > $Null                                                   $ScriptInformation.Add(@{Data = "Key Limit"; Value = $Item.KeyLimit; }) > $Null
                                                }                                           }
                                        }                                   }
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                        -Columns Data,Value `                                   -Columns Data,Value `
                                        -List `                                   -List `
                                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                                        $Table = $Null                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                }                           }
                                If($Text)                           If($Text)
                                {                           {
                                        If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")                                   If($RDSTemplate.LicenseKeyType.ToString() -eq "KMS")
                                        {                                   {
                                                Line 4 "License key management type`t: " "Key Management Service (KMS)"                                           Line 3 "License key management type: " "Key Management Service (KMS)"
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                Line 4 "License key management type`t`t`t: " "Multple Activation Key (MAK)"                                           Line 3 "License key management type: " "Multple Activation Key (MAK)"
                                                                                          
                                                $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null                                           $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $RDSTemplate.Id -EA 0 4>$Null
 
                                                ForEach($Item in $LicenseKeys) <>                                         ForEach($Item in $LicenseKeys)
                                                {                                           {
                                                        Line 4 "License Key`t: " $Item.LicenseKey                                                   Line 3 "License Key`t: " $Item.LicenseKey
                                                        Line 4 "Key Limit`t: " $Item.KeyLimit                                                   Line 3 "Key Limit`t: " $Item.KeyLimit
                                                }                                           }
                                        }                                   }
                                        Line 0 ""                                   Line 0 ""
                                }                           }
                                If($HTML)                           If($HTML)
                                {                           {
                                        $rowdata = @()                                   $rowdata = @()
                                        If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")                                   If($RDSTemplate.LicenseKeyType.ToString() -eq "KMS")
                                        {                                   {
                                                $columnHeaders = @("License key management type",($Script:htmlsb),"Key Management Service (KMS)",$htmlwhite)                                           $columnHeaders = @("License key management type",($Script:htmlsb),"Key Management Service (KMS)",$htmlwhite)
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $columnHeaders = @("License key management type",($Script:htmlsb),"Multple Activation Key (MAK)",$htmlwhite)                                           $columnHeaders = @("License key management type",($Script:htmlsb),"Multple Activation Key (MAK)",$htmlwhite)
                                                                                          
                                                $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null                                           $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $RDSTemplate.Id -EA 0 4>$Null
 
                                                $cnt = -1 <>                                         $cnt = -1
                                                ForEach($Item in $LicenseKeys)                                           ForEach($Item in $LicenseKeys)
                                                {                                           {
                                                        $rowdata += @(,("License Key",($Script:htmlsb),$Item.LicenseKey,$htmlwhite))                                                   $rowdata += @(,("License Key",($Script:htmlsb),$Item.LicenseKey,$htmlwhite))
                                                        $rowdata += @(,("Key Limit",($Script:htmlsb),$Item.KeyLimit,$htmlwhite))                                                   $rowdata += @(,("Key Limit",($Script:htmlsb),$Item.KeyLimit,$htmlwhite))
                                                }                                           }
                                        }                                   }
 
                                        $msg = "License Keys" <>                                 $msg = "License Keys"
                                        $columnWidths = @("200","275")                                   $columnWidths = @("200","275")
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                }                           }
                        }                   }
                }           }
                ElseIf($? -and $Null -eq $VDITemplates)    
                {    
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 0 0 "No VDI Templates found for Site $($Site.Name)"    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 0 "No VDI Templates found for Site $($Site.Name)"    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 0 0 "No VDI Templates found for Site $($Site.Name)"    
                                WriteHTMLLine 0 0 ""    
                        }    
                }    
                Else    
                {    
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"    
                                WriteHTMLLine 0 0 ""    
                        }    
                }    
                    
                #Desktops    
                #can't find this    
        }    
 
        #Remote PCs are not in PoSH <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Hosts Scheduler"
            
        $GWs = Get-RASGW -Siteid $Site.Id -EA 0 4> $Null           $RDSSchedules = Get-RASRDSSchedule -Siteid $Site.Id -EA 0 4> $Null
 
                Unable to retrieve Gateways for Site $($Site.Name)` <>                 Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)`
 
                        WriteWordLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)"
 
                        Line 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)"
 
        ElseIf($? -and $Null -eq $GWs) <>         ElseIf($? -and $Null -eq $RDSSchedules)
 
                No Gateways retrieved for Site $($Site.Name).` <>                 No RD Session Host Scheduler retrieved for Site $($Site.Name).`
 
                        WriteWordLine 0 0 "No Gateways retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"
 
                        Line 0 "No Gateways retrieved for Site $($Site.Name)" <>                         Line 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No Gateways retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"
 
                        WriteWordLine 2 0 "Gateways" <>                         WriteWordLine 2 0 "Scheduler"
 
                        Line 1 "Gateways" <>                         Line 1 "Scheduler"
 
                        WriteHTMLLine 2 0 "Gateways" <>                         WriteHTMLLine 2 0 "Scheduler"
 
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Gateways" <>                 ForEach($RDSSchedule in $RDSSchedules)
                ForEach($GW in $GWs)    
 
                        $GWStatus = Get-RASGWStatus -Id $GW.Id -EA 0 4>$Null <>                         Write-Verbose "$(Get-Date -Format G): `t`t`tOutput RD Session Host Scheduler $($RDSSchedule.Name)"
                                                  $Action = $RDSSchedule.Action
                        If(!$?)                           If($RDSSChedule.Action -eq "Reboot")
 
                                Write-Warning " <>                                 If($RDSSchedule.DrainMode)
                                `n    
                                Unable to retrieve Gateway Status for Gateway $($GW.Id)`    
                                "    
                                If($MSWord -or $PDF)    
 
                                        WriteWordLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)" <>                                         $Action = "Reboot - Drain Mode"
 
                                If($Text) <>                                 Else
 
                                        Line 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)" <>                                         $Action = "Reboot"
 
                                If($HTML) <>  
                                {    
                                        WriteHTMLLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)"    
                                }                           }
                                #unable to retrieve    
                                $GWEnableHSTS            = "Unable to retrieve Gateway Status"    
                                $GWEnableSSL             = "Unable to retrieve Gateway Status"    
                                $GWEnableSSLOnPort       = "Unable to retrieve Gateway Status"    
                                $GWAcceptedSSLVersions   = "Unable to retrieve Gateway Status"    
                                $GWCipherStrength        = "Unable to retrieve Gateway Status"    
                                $GWCipher                = "Unable to retrieve Gateway Status"    
                                $GWCertificates          = "Unable to retrieve Gateway Status"    
                                $GWHSTSMaxage            = "Unable to retrieve Gateway Status"    
                                $GWHSTSIncludeSubdomains = "Unable to retrieve Gateway Status"    
                                $GWHSTSPreload           = "Unable to retrieve Gateway Status"    
                        }    
                        ElseIf($? -and $Null -eq $GWStatus)                           <#If($Action -eq "Reboot - Drain Mode")
 
                                Write-Host " <>                                 Switch ($RDSSchedule.CompleteRebootInSecs)
                                No Gateway Status retrieved for Gateway $($GW.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
 
                                        WriteWordLine 0 0 "No Gateway Status found for Gateway $($GW.Id)" <>                                         600             {$TimeDuration = "10 minutes"; Break}
                                            900             {$TimeDuration = "15 minutes"; Break}
                                            1800    {$TimeDuration = "30 minutes"; Break}
                                            2700    {$TimeDuration = "45 minutes"; Break}
                                            3600    {$TimeDuration = "1 hour"; Break}
                                            7200    {$TimeDuration = "2 hours"; Break}
                                            10800   {$TimeDuration = "3 hours"; Break}
                                            Default {$TimeDuration = "Unable to determine Complete in seconds: $($RDSSchedule.CompleteRebootInSecs)"; Break}
 
                                If($Text) <>                                
                                    Switch ($RDSSchedule.ForceRebootAfterSecs)
 
                                        Line 0 "No Gateway Status found for Gateway $($GW.Id)" <>                                         900             {$ForceRebootTime = "15 minutes"; Break}
                                            1800    {$ForceRebootTime = "30 minutes"; Break}
                                            2700    {$ForceRebootTime = "45 minutes"; Break}
                                            3600    {$ForceRebootTime = "1 hour"; Break}
                                            7200    {$ForceRebootTime = "2 hours"; Break}
                                            10800   {$ForceRebootTime = "3 hours"; Break}
                                            21600   {$ForceRebootTime = "6 hours"; Break}
                                            43200   {$ForceRebootTime = "12 hours"; Break}
                                            86400   {$ForceRebootTime = "1 day"; Break}
                                            Default {$ForceRebootTime = "Unable to determine Force reboot after seconds: $($RDSSchedule.ForceRebootAfterSecs)"; Break}
 
                                If($HTML) <>  
                                {    
                                        WriteHTMLLine 0 0 "No Gateway Status found for Gateway $($GW.Id)"    
                                }                           }#>
                            <#RDSSchedItem  
                            Dropped Properties      DurationInSecs
                                                                    EndDateTime
                                #set all to blank                                                                   DisableAction
                                $GWEnableHSTS            = ""    
                                $GWEnableSSL             = ""    
                                $GWEnableSSLOnPort       = ""    
                                $GWAcceptedSSLVersions   = ""    
                                $GWCipherStrength        = ""    
                                $GWCipher                = ""    
                                $GWCertificates          = ""    
                                $GWHSTSMaxage            = ""    
                                $GWHSTSIncludeSubdomains = ""    
                                $GWHSTSPreload           = ""    
                        }                           #>
                        Else                           <#ElseIf($Action -eq "Disable")
 
                                If($GW.InheritDefaultSslTlsSettings) <>                                 Switch ($RDSSchedule.DurationInSecs)
 
                                        #do we inherit site defaults? <>                                         600             {$TimeDuration = "10 minutes"; Break}
                                        #yes we do, get the default settings for the Site                                           900             {$TimeDuration = "15 minutes"; Break}
                                        #use the Site default settings                                           1800    {$TimeDuration = "30 minutes"; Break}
                                            2700    {$TimeDuration = "45 minutes"; Break}
                                        $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null                                           3600    {$TimeDuration = "1 hour"; Break}
                                                                                  7200    {$TimeDuration = "2 hours"; Break}
                                        If($? -and $Null -ne $GWDefaults)                                           10800   {$TimeDuration = "3 hours"; Break}
                                        {                                           21600   {$TimeDuration = "6 hours"; Break}
                                                If($GWDefaults.EnableHSTS)                                           43200   {$TimeDuration = "12 hours"; Break}
                                                {                                           86400   {$TimeDuration = "1 day"; Break}
                                                        $GWEnableHSTS            = $GWDefaults.EnableHSTS.ToString()    
                                                        $GWHSTSMaxage            = $GWDefaults.HSTSMaxAge.ToString()    
                                                        $GWHSTSIncludeSubdomains = $GWDefaults.HSTSIncludeSubdomains.ToString()                                           Default {$TimeDuration = "Unable to determine Duration in seconds: $($RDSSchedule.DurationInSecs)"; Break}
                                                        $GWHSTSPreload           = $GWDefaults.HSTSPreload.ToString()    
                                                }                                   }
                                                Else                                  
                                    Switch ($RDSSchedule.DisableAction)
                                                {                                   {
                                                        $GWEnableHSTS = $GWDefaults.EnableHSTS.ToString()                                           "KeepSessionState"                      {$OnDisable = "Keep current sessions state"; Break}
                                            "DisconnectActiveSessions"      {$OnDisable = "Disconnect any active session"; Break}
                                            "ResetAllSessions"                      {$OnDisable = "Reset all sessions"; Break}
                                            Default                                         {$OnDisable = "Unable to determine On disable: $($RDSSchedule.DisableAction)"; Break}
                                                }                                   }
                                                $GWEnableSSL       = $GWDefaults.EnableSSL.ToString()                           }#>
                                                $GWEnableSSLOnPort = $GWDefaults.SSLPort.ToString()    
                                                                          
                                                Switch ($GWDefaults.MinSSLVersion)                           Switch ($RDSSchedule.Repeat)
                                                {                           {
                                                        "SSLv2"         {$GWAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}                                   Never                   {$Repeat = "Never "; Break}
                                                        "SSLv3"         {$GWAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}                                   EveryDay                {$Repeat = "Every day"; Break}
                                                        "TLSv1"         {$GWAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}                                   EveryWeek               {$Repeat = "Every week"; Break}
                                                        "TLSv1_1"       {$GWAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}                                   Every2Weeks             {$Repeat = "Every 2 weeks"; Break}
                                                        "TLSv1_2"       {$GWAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}                                   EveryMonth              {$Repeat = "Every month"; Break}
                                    EveryYear               {$Repeat = "Every year"; Break}
                                    SpecificDays    {$Repeat = "Every $($RDSSchedule.SpecificDays)"; Break}
                                                        Default         {$GWAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($GWDefaults.MinSSLVersion)"; Break}                                   Default                 {$Repeat = "Unable to determine the Repeat: $($RDSSchedule.Repeat)"; Break}
                                                }                           }
                                                                          
                                                $GWCipherStrength = $GWDefaults.CipherStrength.ToString()                           $Target = @()
                                                $GWCipher         = $GWDefaults.Cipher                           If($RDSSchedule.TargetType -eq "Server")
                                                    
                                                If($GWDefaults.CertificateId -eq 0)    
                                                {                           {
                                                        $GWCertificates = "All matching usage"                                   ForEach($Item in $RDSSchedule.TargetIds)
                                                }    
                                                Else    
                                                {                                   {
                                                        $Results = Get-RASCertificate -Id $GWDefaults.CertificateId -EA 0 4>$Null                                           $Result = Get-RASRDS -Id $Item -EA 0 4>$Null
                                                                                                  
                                                        If($? -and $Null -ne $Results)                                           If($? -and $Null -ne $Result)
                                                        {                                           {
                                                                $GWCertificates = $Results.Name                                                   $Target += $Result.Server
                                                        }                                           }
                                                        Else                                           Else
                                                        {                                           {
                                                                $GWCertificates = "Unable to determin Gateway Certificate: $($GWDefaults.CertificateId)"                                                   Target += "Unable to find RDS Server for ID $($Item)"
                                                        }                                           }
                                                }                                   }
                                        }                           }
                                        Else                           ElseIf($RDSSchedule.TargetType -eq "ServerGroup")
                                        {                           {
                                                #unable to retrieve default, use built-in default values                                   ForEach($Item in $RDSSchedule.TargetIds)
                                                $GWEnableHSTS          = "False"    
                                                $GWEnableSSL           = "True"    
                                                $GWEnableSSLOnPort     = "443"    
                                                $GWAcceptedSSLVersions = "TLS v1 - TLS v1.2"    
                                                $GWCipherStrength      = "High"    
                                                $GWCipher              = "EECDH:!SSLv2:!SSLv3:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"    
                                                $GWCertificates        = "All matching usage"    
                                        }    
                                }    
                                Else    
 
                                        #we don't inherit settings <>                                         $Result = Get-RASRDSGroup -Id $Item -EA 0 4>$Null
                                        #get the settings configured for this GW                                          
                                        If($GW.EnableHSTS)                                           If($? -and $Null -ne $Result)
 
                                                $GWEnableHSTS            = $GW.EnableHSTS.ToString() <>                                                 $Target += $Result.Name
                                                $GWHSTSMaxage            = $GW.HSTSMaxAge.ToString()    
                                                $GWHSTSIncludeSubdomains = $GW.HSTSIncludeSubdomains.ToString()    
                                                $GWHSTSPreload           = $GW.HSTSPreload.ToString()    
 
                                                $GWEnableHSTS = $GW.EnableHSTS.ToString() <>                                                 Target += "Unable to find RDS Server Group for ID $($Item)"
 
                                        $GWEnableSSL       = $GW.EnableSSL.ToString() <>  
                                        $GWEnableSSLOnPort = $GW.SSLPort.ToString()    
                                            
                                        Switch ($GW.MinSSLVersion)    
                                        {                                   }
                                                "SSLv2"         {$GWAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}    
                                                "SSLv3"         {$GWAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}    
                                                "TLSv1"         {$GWAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}    
                                                "TLSv1_1"       {$GWAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}    
                                                "TLSv1_2"       {$GWAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}    
                                                Default         {$GWAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($GW.MinSSLVersion)"; Break}    
                                        }                           }
                                                                  Else
                                        $GWCipherStrength = $GW.CipherStrength.ToString()    
                                        $GWCipher         = $GW.Cipher    
                                            
                                        If($GW.CertificateId -eq 0)    
                                        {                           {
                                                $GWCertificates = "All matching usage"                                   Target += "Unable to determine Target for TargetType: $($RDSSchedule.TargetType)"
                                        }                           }
                                        Else                          
                            If($MSWord -or $PDF)
                                        {                           {
                                                $Results = Get-RASCertificate -Id $GW.CertificateId -EA 0 4>$Null                                   WriteWordLine 3 0 "Schedule Name $($RDSSchedule.Name)"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null
                                                                                  
                                                If($? -and $Null -ne $Results)                                   $cnt=-1
                                    ForEach($Item in $Target)
                                                {                                   {
                                                        #double replace to remove the < and > from the cert name so it doesn't mess up HTML output                                           $cnt++
                                                        $GWCertificates = $Results.Name.Replace("<","").Replace(">","")                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        $GWCertificates = "Unable to determine Gateway Certificate: $($GW.CertificateId)"                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                                }    
 
                                $GWStatusAgentState = GetRASStatus $GWStatus.AgentState <>  
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 3 0 "Gateways $($GW.Server)"    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Server"; Value = $GW.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Mode"; Value = $GW.GWMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "Repeat"; Value = $Repeat; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $GWStatusAgentState; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $GW.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Certificate"; Value = $GWCertificates; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Log level"; Value = $GWStatus.LogLevel; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $GW.AdminLastMod; }) > $Null                                   $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RDSSchedule.AdminLastMod; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $GW.TimeLastMod.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Modified on"; Value = $RDSSchedule.TimeLastMod.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $GW.AdminCreate; }) > $Null                                   $ScriptInformation.Add(@{Data = "Created by"; Value = $RDSSchedule.AdminCreate; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $GW.TimeCreate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Created on"; Value = $RDSSchedule.TimeCreate.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $GW.Id.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "ID"; Value = $RDSSchedule.Id.ToString(); }) > $Null
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                        -Columns Data,Value `                                   -Columns Data,Value `
                                        -List `                                   -List `
                                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 250;
                                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                                        $Table = $Null                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                }                           }
                                If($Text)                           If($Text)
                                {                           {
                                        Line 2 "Gateways $($GW.Server)"    
                                        Line 3 "Server`t`t`t: " $GW.Server                                   Line 2 "Name`t`t`t: " $RDSSchedule.Name
                                    Line 2 "Action`t`t`t: " $Action
                                    
                                    $cnt=-1
                                    ForEach($Item in $Target)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                        Line 3 "Mode`t`t`t: " $GW.GWMode                                                   Line 2 "Target`t`t`t: " $Item
                                            }
                                            Else
                                            {
                                                    Line 6 "  " $Item
                                            }
                                    }
                                    
                                        Line 3 "Status`t`t`t: " $GWStatusAgentState                                   Line 2 "Start`t`t`t: " $RDSSchedule.StartDateTime
                                    Line 2 "Repeat`t`t`t: " $Repeat
                                        Line 3 "Description`t`t: " $GW.Description                                   Line 2 "Description`t`t: " $RDSSchedule.Description
                                        Line 3 "Certificate`t`t: " $GWCertificates    
                                        Line 3 "Log level`t`t: " $GWStatus.LogLevel    
                                        Line 3 "Last modification by`t: " $GW.AdminLastMod                                   Line 2 "Last modification by`t: " $RDSSchedule.AdminLastMod
                                        Line 3 "Modified on`t`t: " $GW.TimeLastMod.ToString()                                   Line 2 "Modified on`t`t: " $RDSSchedule.TimeLastMod.ToString()
                                        Line 3 "Created by`t`t: " $GW.AdminCreate                                   Line 2 "Created by`t`t: " $RDSSchedule.AdminCreate
                                        Line 3 "Created on`t`t: " $GW.TimeCreate.ToString()                                   Line 2 "Created on`t`t: " $RDSSchedule.TimeCreate.ToString()
                                        Line 3 "ID`t`t`t: " $GW.Id.ToString()                                   Line 2 "ID`t`t`t: " $RDSSchedule.Id.ToString()
                                        Line 0 ""                                   Line 0 ""
                                }                           }
                                If($HTML)                           If($HTML)
                                {                           {
                                        WriteHTMLLine 3 0 "Gateways $($GW.Server)"                                   WriteHTMLLine 3 0 "Schedule Name $($RDSSchedule.Name)"
                                        $rowdata = @()                                   $rowdata = @()
                                        $columnHeaders = @("Server",($Script:htmlsb),$GW.Server,$htmlwhite)                                   $columnHeaders = @("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite)
                                        $rowdata += @(,("Mode",($Script:htmlsb),$GW.GWMode.ToString(),$htmlwhite))                                   $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))
                                    
                                    $cnt=-1
                                    ForEach($Item in $Target)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                        $rowdata += @(,("Status",($Script:htmlsb),$GWStatusAgentState.ToString(),$htmlwhite))                                                   $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                            Else
                                            {
                                        $rowdata += @(,("Description",($Script:htmlsb),$GW.Description,$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    
                                        $rowdata += @(,("Certificate",($Script:htmlsb),$GWCertificates,$htmlwhite))                                   $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime,$htmlwhite))
                                        $rowdata += @(,("Log level",($Script:htmlsb),$GWStatus.LogLevel,$htmlwhite))                                   $rowdata += @(,("Repeat",($Script:htmlsb),$Repeat,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $GW.AdminLastMod,$htmlwhite))                                   $rowdata += @(,("Last modification by",($Script:htmlsb),$RDSSchedule.AdminLastMod,$htmlwhite))
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $GW.TimeLastMod.ToString(),$htmlwhite))                                   $rowdata += @(,("Modified on",($Script:htmlsb),$RDSSchedule.TimeLastMod.ToString(),$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $GW.AdminCreate,$htmlwhite))                                   $rowdata += @(,("Created by",($Script:htmlsb),$RDSSchedule.AdminCreate,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $GW.TimeCreate.ToString(),$htmlwhite))                                   $rowdata += @(,("Created on",($Script:htmlsb),$RDSSchedule.TimeCreate.ToString(),$htmlwhite))
                                        $rowdata += @(,("ID",($Script:htmlsb),$GW.Id.ToString(),$htmlwhite))                                   $rowdata += @(,("ID",($Script:htmlsb),$RDSSchedule.Id.ToString(),$htmlwhite))
 
                                        $msg = "" <>                                 $msg = ""
                                        $columnWidths = @("300","275")                                   $columnWidths = @("200","275")
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                }                           }
                        }                          
                            #Properties
 
                        Switch ($GW.IPVersion) +-  
                        {    
                                "Version4"              {$IPVersion = "Version 4"; Break}    
                                "Version6"              {$IPVersion = "Version 6"; Break}    
                                "BothVersions"  {$IPVersion = "Both version 4 & 6"; Break}    
                                Default                 {$IPVersion = "Unable to determine IP version: $($GW.IPVersion)"; Break}    
                        }    
                            
                        $GWIPs = $GW.IPs.Split(";")    
                            
                        If($GW.BindV4Addresses -eq "")    
                        {    
                                $GWBindV4Addresses = "All available addresses"    
                        }    
                        Else    
                        {    
                                $GWBindV4Addresses = $GW.BindV4Addresses    
                        }    
     
                        If($GW.OptimizeConnectionIPv4 -eq "<All>")    
                        {    
                                $GWOptimizeV4 = "All available addresses"    
                        }    
                        ElseIf($GW.OptimizeConnectionIPv4 -eq "<None>")    
                        {    
                                $GWOptimizeV4 = "None from the available"    
                        }    
                        Else    
                        {    
                                $GWOptimizeV4 = $GW.OptimizeConnectionIPv4    
                        }    
     
                        If($GW.BindV6Addresses -eq "")    
                        {    
                                $GWBindV6Addresses = "All available addresses"    
                        }    
                        Else    
                        {    
                                $GWBindV6Addresses = $GW.BindV6Addresses    
                        }    
     
                        If($GW.OptimizeConnectionIPv6 -eq "<All>")    
                        {    
                                $GWOptimizeV6 = "All available addresses"    
                        }    
                        ElseIf($GW.OptimizeConnectionIPv6 -eq "<None>")    
                        {    
                                $GWOptimizeV6 = "None from the available"    
                        }    
                        Else    
                        {    
                                $GWOptimizeV6 = $GW.OptimizeConnectionIPv6    
                        }    
     
 
                                $ScriptInformation.Add(@{Data = "Enable RAS Secure Client Gateway in Site"; Value = $GW.Enabled.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Enable Schedule"; Value = $RDSSchedule.Enabled.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Server"; Value = $GW.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $GW.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null
                                $ScriptInformation.Add(@{Data = "IP version"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Use IP version"; Value = $IPVersion; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null
 
                                $cnt = -1 <>                                 $cnt=-1
                                ForEach($Item in $GWIPs)                                   ForEach($Item in $Target)
 
                                        If($cnt -eq 0 ) <>                                         If($cnt -eq 0)
 
                                                $ScriptInformation.Add(@{Data = "     IP(s)"; Value = $Item; }) > $Null <>  
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                                   $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null
                                        }    
                                }    
                                    
                                $ScriptInformation.Add(@{Data = "Bind to IP"; Value = ""; }) > $Null    
                                If($GW.IPVersion -ne "Version6")    
                                {    
                                        $ScriptInformation.Add(@{Data = "     Bind to the following IPv4"; Value = $GWBindV4Addresses; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $GWOptimizeV4; }) > $Null    
                                }    
                                If($GW.IPVersion -ne "Version4")    
                                {    
                                        $ScriptInformation.Add(@{Data = "     Bind to the following IPv6"; Value = $GWBindV6Addresses; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $GWOptimizeV6; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Enable RAS Secure Client Gateway in Site: " $GW.Enabled.ToString()    
                                Line 3 "Server`t`t`t`t`t: " $GW.Server    
                                Line 3 "Description`t`t`t`t: " $GW.Description    
                                Line 3 "IP version" ""    
                                Line 4 "Use IP version`t`t`t: " $IPVersion    
                                    
                                $cnt = -1    
                                ForEach($Item in $GWIPs)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0 )    
                                        {    
                                                Line 4 "IP(s)`t`t`t`t: " $Item    
                                        }    
                                        Else    
                                        {    
                                                Line 8 "  " $Item    
                                        }    
                                }    
                                    
                                Line 3 "Bind to IP" ""    
                                If($GW.IPVersion -ne "Version6")    
                                {    
                                        Line 4 "Bind to the following IPv4`t: " $GWBindV4Addresses    
                                        Line 4 "Remove system buffers for`t: " $GWOptimizeV4    
                                }    
                                If($GW.IPVersion -ne "Version4")    
                                {    
                                        Line 4 "Bind to the following IPv6`t: " $GWBindV6Addresses    
                                        Line 4 "Remove system buffers for`t: " $GWOptimizeV6    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Enable RAS Secure Client Gateway in Site",($Script:htmlsb),$GW.Enabled.ToString(),$htmlwhite)    
                                $rowdata += @(,("Server",($Script:htmlsb),$GW.Server,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$GW.Description,$htmlwhite))    
                                $rowdata += @(,("IP version",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("     Use IP version",($Script:htmlsb),$IPVersion,$htmlwhite))    
                                    
                                $cnt = -1    
                                ForEach($Item in $GWIPs)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0 )    
                                        {    
                                                $rowdata += @(,("     IP(s)",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                    
                                $rowdata += @(,("Bind to IP",($Script:htmlsb),"",$htmlwhite))    
                                If($GW.IPVersion -ne "Version6")    
                                {    
                                        $rowdata += @(,("     Bind to the following IPv4",($Script:htmlsb),$GWBindV4Addresses,$htmlwhite))    
                                        $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$GWOptimizeV4,$htmlwhite))    
                                }    
                                If($GW.IPVersion -ne "Version4")    
                                {    
                                        $rowdata += @(,("     Bind to the following IPv6",($Script:htmlsb),$GWBindV6Addresses,$htmlwhite))    
                                        $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$GWOptimizeV6,$htmlwhite))    
                                }    
     
                                $msg = "General"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        #Mode    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Mode"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Mode"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($GW.InheritDefaultModeSettings)    
                        {    
                                #do we inherit site defaults?    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
     
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
                                {    
                                        $GWMode = $GWDefaults.GWMode.ToString()    
                                        $GWForwardRequests = $GWDefaults.NormalModeForwarding.ToString()    
                                        If($GWMode -eq "Normal")    
                                        {    
                                                $GWServers = $GWDefaults.ForwardHttpServers.Split(";")    
                                        }    
                                        Else    
                                        {    
                                                $GWServers = $GWDefaults.ForwardGatewayServers.Split(";")    
                                        }    
                                    
                                        If($GWDefaults.PreferredPAId -eq 0)    
                                        {    
                                                $GWPreferredPublishingAgent = "Automatically"    
                                        }    
                                        Else    
                                        {    
                                                $GWPreferredPublishingAgent = (Get-RASPA -Id $GWDefaults.PreferredPAId -EA 0 4>$Null).Server    
                                        }    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $GWMode = "Normal"    
                                        $GWForwardRequests = "False"    
                                        $GWServers = @("localhost:81")    
                                        $GWPreferredPublishingAgent = "Automatically"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                $GWMode = $GW.GWMode.ToString()    
                                $GWForwardRequests = $GW.NormalModeForwarding.ToString()    
                                If($GWMode -eq "Normal")    
                                {    
                                        $GWServers = $GW.ForwardHttpServers.Split(";")    
                                }    
                                Else    
                                {    
                                        $GWServers = $GW.ForwardGatewayServers.Split(";")    
                                }    
                            
                                If($GW.PreferredPAId -eq 0)    
                                {    
                                        $GWPreferredPublishingAgent = "Automatically"    
                                }    
                                Else    
                                {    
                                        $GWPreferredPublishingAgent = (Get-RASPA -Id $GW.PreferredPAId -EA 0 4>$Null).Server    
                                }    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultModeSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Gateway mode"; Value = $GWMode; }) > $Null    
                                    
                                If($GWMode -eq "Normal")    
                                {    
                                        If($GWForwardRequests -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Forward requests to HTTP Server"; Value = $GWForwardRequests; }) > $Null    
                                                    
                                                $cnt = -1    
                                                ForEach($Item in $GWServers)    
                                                {    
                                                        $cnt++    
                                                        $tmparray = $Item.Split(":")    
                                                        $tmpserver = $tmparray[0]    
                                                        $tmpport = $tmparray[1]    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "Server(s)"; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                            
                                        $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $GWPreferredPublishingAgent; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Forward requests to next RAS Secure Client Gateway in chain (cascaded firewall)"; Value = $GWForwardRequests; }) > $Null    
                                            
                                        If($GWForwardRequests -eq "True")    
                                        {    
                                                $cnt = -1    
                                                ForEach($Item in $GWServers)    
                                                {    
                                                        $cnt++    
                                                        $tmparray = $Item.Split(":")    
                                                        $tmpserver = $tmparray[0]    
                                                        $tmpport = $tmparray[1]    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "Server(s)"; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultModeSettings.ToString()    
                                Line 3 "Gateway mode`t`t`t`t: " $GWMode    
                                If($GWMode -eq "Normal")    
                                {    
                                        Line 3 "Forward requests to HTTP Server`t`t: " $GWForwardRequests    
                                            
                                        $cnt = -1    
                                        ForEach($Item in $GWServers)    
                                        {    
                                                $cnt++    
                                                $tmparray = $Item.Split(":")    
                                                $tmpserver = $tmparray[0]    
                                                $tmpport = $tmparray[1]    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 3 "Server(s)`t`t`t`t: " "Server: $($tmpserver)`tPort: $($tmpport)"    
                                                }    
                                                Else    
                                                {    
                                                        Line 8 "  " "Server: $($tmpserver)`tPort: $($tmpport)"    
                                                }    
                                        }    
                                            
                                        Line 3 "Preferred Publishing Agent`t`t: " $GWPreferredPublishingAgent    
                                }    
                                Else    
                                {    
                                        Line 3 "Forward requests to next "    
                                        Line 3 "RAS Secure Client Gateway"    
                                        Line 3 "in chain (cascaded firewall)`t`t: " $GWForwardRequests    
                                            
                                        $cnt = -1    
                                        ForEach($Item in $GWServers)    
                                        {    
                                                $cnt++    
                                                $tmparray = $Item.Split(":")    
                                                $tmpserver = $tmparray[0]    
                                                $tmpport = $tmparray[1]    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 3 "Server(s)`t`t`t`t: " "Server: $($tmpserver)`tPort: $($tmpport)"    
                                                }    
                                                Else    
                                                {    
                                                        Line 8 "  " "Server: $($tmpserver)`tPort: $($tmpport)"    
                                                }    
                                        }    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultModeSettings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Gateway mode",($Script:htmlsb),$GWMode,$htmlwhite))    
                                If($GWMode -eq "Normal")    
                                {    
                                        $rowdata += @(,("Forward requests to HTTP Server",($Script:htmlsb),$GWForwardRequests,$htmlwhite))    
                                            
                                        $cnt = -1    
                                        ForEach($Item in $GWServers)    
                                        {    
                                                $cnt++    
                                                $tmparray = $Item.Split(":")    
                                                $tmpserver = $tmparray[0]    
                                                $tmpport = $tmparray[1]    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Server(s)",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))    
                                                }    
                                        }    
                                            
                                        $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$GWPreferredPublishingAgent,$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Forward requests to next RAS Secure Client Gateway in chain (cascaded firewall)",($Script:htmlsb),$GWForwardRequests,$htmlwhite))    
                                            
                                        $cnt = -1    
                                        ForEach($Item in $GWServers)    
                                        {    
                                                $cnt++    
                                                $tmparray = $Item.Split(":")    
                                                $tmpserver = $tmparray[0]    
                                                $tmpport = $tmparray[1]    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Server(s)",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))    
                                                }    
                                        }    
                                }    
     
                                $msg = "Mode"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Network    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Network"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Network"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($GW.InheritDefaultNetworkSettings)    
                        {    
                                #do we inherit site defaults?    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
     
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
                                {    
                                        $GWEnableRASSecureClientGatewayPort             = $GWDefaults.EnableGWPort.ToString()    
                                        $GWRASSecureClientGatewayPort                   = $GWDefaults.GWPort.ToString()    
                                        $GWEnableRDPPort                                = $GWDefaults.EnableRDP.ToString()    
                                        $GWRDPPort                                      = $GWDefaults.RDPPort.ToString()    
                                        $GWEnableBroadcastRASSecureClientGatewayAddress = $GWDefaults.Broadcast.ToString()    
                                        $GWEnableRDPUPDDataTunneling                    = $GWDefaults.EnableRDPUDP.ToString()    
                                        $GWEnableClientManagerPort                      = $GWDefaults.EnableClientManagerPort.ToString()    
                                        $GWClientManagerPort                            = "20009"    
                                        $GWEnableRDPDOSAttackFilter                     = $GWDefaults.DOSPro.ToString()    
                                        $GWCipherPreference                             = $GWDefaults.CipherPreference.ToString()    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $GWEnableRASSecureClientGatewayPort             = "True"    
                                        $GWRASSecureClientGatewayPort                   = "80"    
                                        $GWEnableRDPPort                                = "False"    
                                        $GWEnableBroadcastRASSecureClientGatewayAddress = "True"    
                                        $GWEnableRDPUPDDataTunneling                    = "True"    
                                        $GWEnableClientManagerPort                      = "True"    
                                        $GWClientManagerPort                            = "20009"    
                                        $GWEnableRDPDOSAttackFilter                     = "True"    
                                        $GWCipherPreference                             = "True"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                $GWEnableRASSecureClientGatewayPort             = $GW.EnableGWPort.ToString()    
                                $GWRASSecureClientGatewayPort                   = $GW.GWPort.ToString()    
                                $GWEnableRDPPort                                = $GW.EnableRDP.ToString()    
                                $GWRDPPort                                      = $GW.RDPPort.ToString()    
                                $GWEnableBroadcastRASSecureClientGatewayAddress = $GW.Broadcast.ToString()    
                                $GWEnableRDPUPDDataTunneling                    = $GW.EnableRDPUDP.ToString()    
                                $GWEnableClientManagerPort                      = $GW.EnableClientManagerPort.ToString()    
                                $GWClientManagerPort                            = "20009"    
                                $GWEnableRDPDOSAttackFilter                     = $GW.DOSPro.ToString()    
                                $GWCipherPreference                             = $GW.CipherPreference.ToString()    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultNetworkSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable RAS Secure Client Gateway Port"; Value = $GWEnableRASSecureClientGatewayPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "RAS Secure Client Gateway Port"; Value = $GWRASSecureClientGatewayPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable RDP Port"; Value = $GWEnableRDPPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "RDP Port"; Value = $GWRDPPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable Broadcast RAS Secure Client Gateway Address"; Value = $GWEnableBroadcastRASSecureClientGatewayAddress; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable RDP UDP Data Tunneling"; Value = $GWEnableRDPUPDDataTunneling; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable Client Manager Port"; Value = $GWEnableClientManagerPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Client Manager Port"; Value = $GWClientManagerPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable RDP DOS Attack Filter"; Value = $GWEnableRDPDOSAttackFilter; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultNetworkSettings.ToString()    
                                Line 3 "Enable RAS Secure Client Gateway Port`t: " $GWEnableRASSecureClientGatewayPort    
                                Line 3 "RAS Secure Client Gateway Port`t`t: " $GWRASSecureClientGatewayPort    
                                Line 3 "Enable RDP Port`t`t`t`t: " $GWEnableRDPPort    
                                Line 3 "RDP Port`t`t`t`t: " $GWRDPPort    
                                Line 3 "Enable Broadcast RAS Secure "    
                                Line 3 "Client Gateway Address`t`t`t: " $GWEnableBroadcastRASSecureClientGatewayAddress    
                                Line 3 "Enable RDP UDP Data Tunneling`t`t: " $GWEnableRDPUPDDataTunneling    
                                Line 3 "Enable Client Manager Port`t`t: " $GWEnableClientManagerPort    
                                Line 3 "Client Manager Port`t`t`t: " $GWClientManagerPort    
                                Line 3 "Enable RDP DOS Attack Filter`t`t: " $GWEnableRDPDOSAttackFilter    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultNetworkSettings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Enable RAS Secure Client Gateway Port",($Script:htmlsb),$GWEnableRASSecureClientGatewayPort,$htmlwhite))    
                                $rowdata += @(,("RAS Secure Client Gateway Port",($Script:htmlsb),$GWRASSecureClientGatewayPort,$htmlwhite))    
                                $rowdata += @(,("Enable RDP Port",($Script:htmlsb),$GWEnableRDPPort,$htmlwhite))    
                                $rowdata += @(,("RDP Port",($Script:htmlsb),$GWRDPPort,$htmlwhite))    
                                $rowdata += @(,("Enable Broadcast RAS Secure Client Gateway Address",($Script:htmlsb),$GWEnableBroadcastRASSecureClientGatewayAddress,$htmlwhite))    
                                $rowdata += @(,("Enable RDP UDP Data Tunneling",($Script:htmlsb),$GWEnableRDPUPDDataTunneling,$htmlwhite))    
                                $rowdata += @(,("Enable Client Manager Port",($Script:htmlsb),$GWEnableClientManagerPort,$htmlwhite))    
                                $rowdata += @(,("Client Manager Port",($Script:htmlsb),$GWClientManagerPort,$htmlwhite))    
                                $rowdata += @(,("Enable RDP DOS Attack Filter",($Script:htmlsb),$GWEnableRDPDOSAttackFilter,$htmlwhite))    
     
                                $msg = "Network"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #SSL/TLS    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "SSL/TLS"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "SSL/TLS"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultSslTlsSettings.ToString(); }) > $Null    
     
                                If($GWEnableHSTS -eq "False")    
                                {    
                                        $ScriptInformation.Add(@{Data = "HSTS is off"; Value = ""; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "HSTS is on"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Enforce HTTP strict transport security (HSTS)"; Value = $GWEnableHSTS; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Browser caache time"; Value = "$GWHSTSMaxage months"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Include subdomains"; Value = $GWHSTSIncludeSubdomains; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Preload"; Value = $GWHSTSPreload; }) > $Null    
                                }    
     
                                $ScriptInformation.Add(@{Data = "Enable SSL"; Value = $GWEnableSSL; }) > $Null    
                                $ScriptInformation.Add(@{Data = "on Port"; Value = $GWEnableSSLOnPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Accepted SSL Versions"; Value = $GWAcceptedSSLVersions; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Cipher Strength"; Value = $GWCipherStrength; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Cipher"; Value = $GWCipher; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Use ciphers according to server preference"; Value = $GWCipherPreference; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Certificates"; Value = $GWCertificates; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t`t  : " $GW.InheritDefaultSslTlsSettings.ToString()    
     
                                If($GWEnableHSTS -eq "False")    
                                {    
                                        Line 3 "HSTS is off"    
                                }    
                                Else    
                                {    
                                        Line 3 "HSTS is on"    
                                        Line 3 "Enforce HTTP strict transport security`t  : " $GWEnableHSTS    
                                        Line 3 "Browser caache time`t`t`t  : " "$GWHSTSMaxage months"    
                                        Line 3 "Include subdomains`t`t`t  : " $GWHSTSIncludeSubdomains    
                                        Line 3 "Preload`t`t`t`t`t  : " $GWHSTSPreload    
                                }    
     
                                Line 3 "Enable SSL`t`t`t`t  : " $GWEnableSSL    
                                Line 3 "on Port`t`t`t`t`t  : " $GWEnableSSLOnPort    
                                Line 3 "Accepted SSL Versions`t`t`t  : " $GWAcceptedSSLVersions    
                                Line 3 "Cipher Strength`t`t`t`t  : " $GWCipherStrength    
                                Line 3 "Cipher`t`t`t`t`t  : " $GWCipher    
                                Line 3 "Use ciphers according to server preference: " $GWCipherPreference    
                                Line 3 "Certificates`t`t`t`t  : " $GWCertificates    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultSslTlsSettings.ToString(),$htmlwhite)    
     
                                If($GWEnableHSTS -eq "False")    
                                {    
                                        $rowdata += @(,("HSTS is off",($Script:htmlsb),"",$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("HSTS is on",($Script:htmlsb),,$htmlwhite))    
                                        $rowdata += @(,("Enforce HTTP strict transport security (HSTS)",($Script:htmlsb),$GWEnableHSTS,$htmlwhite))    
                                        $rowdata += @(,("Browser caache time",($Script:htmlsb),"$GWHSTSMaxage months",$htmlwhite))    
                                        $rowdata += @(,("Include subdomains",($Script:htmlsb),$GWHSTSIncludeSubdomains,$htmlwhite))    
                                        $rowdata += @(,("Preload",($Script:htmlsb),$GWHSTSPreload,$htmlwhite))    
                                }    
     
                                $rowdata += @(,("Enable SSL",($Script:htmlsb),$GWEnableSSL,$htmlwhite))    
                                $rowdata += @(,("on Port",($Script:htmlsb),$GWEnableSSLOnPort,$htmlwhite))    
                                $rowdata += @(,("Accepted SSL Versions",($Script:htmlsb),$GWAcceptedSSLVersions,$htmlwhite))    
                                $rowdata += @(,("Cipher Strength",($Script:htmlsb),$GWCipherStrength,$htmlwhite))    
                                $rowdata += @(,("Cipher",($Script:htmlsb),$GWCipher,$htmlwhite))    
                                $rowdata += @(,("Use ciphers according to server preference",($Script:htmlsb),$GWCipherPreference,$htmlwhite))    
                                $rowdata += @(,("Certificates",($Script:htmlsb),$GWCertificates,$htmlwhite))    
     
                                $msg = "SSL/TLS"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #HTML5    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "HTML5"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "HTML5"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($GW.InheritDefaultHTML5Settings)    
                        {    
                                #do we inherit site defaults?    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
     
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
                                {    
                                        $GWEnableHTML5Client = $GWDefaults.EnableHTML5.ToString()    
                                            
                                        Switch($GWDefaults.LaunchMethod)    
                                        {    
                                                "ParallelsClientAndHTML5"       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break}    
                                                "ParallelsClient"                       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client"; Break}    
                                                "HTML5"                                         {$GWLaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break}    
                                                Default                                         {$GWLaunchSessionsUsing = "Unable to determine Launch sessions using: $($GWDefaults.LaunchMethod)"; Break}    
                                        }    
                                            
                                        Switch ($GWDefaults.FileTransferMode)    
                                        {    
                                                "Bidirectional"         {$GWFileTransferMode = "Bidirectional"; Break}    
                                                "Disabled"                      {$GWFileTransferMode = "Disabled"; Break}    
                                                "ClientToServer"        {$GWFileTransferMode = "Client to server only"; Break}    
                                                "ServerToClient"        {$GWFileTransferMode = "Server to client only"; Break}    
                                                Default                         {$GWFileTransferMode = "Unable to determine File Transfer mode: $($GWDefaults.FileTransferMode)"; Break}    
                                        }    
     
                                        Switch ($GWDefaults.ClipboardDirection)    
                                        {    
                                                "Bidirectional"         {$GWClipboardTransferMode = "Bidirectional"; Break}    
                                                "Disabled"                      {$GWClipboardTransferMode = "Disabled"; Break}    
                                                "ClientToServer"        {$GWClipboardTransferMode = "Client to server only"; Break}    
                                                "ServerToClient"        {$GWClipboardTransferMode = "Server to client only"; Break}    
                                                Default                         {$GWClipboardTransferMode = "Unable to determine Clipboard mode: $($GWDefaults.ClipboardDirection)"; Break}    
                                        }    
     
                                        $GWAllowLaunchMethod          = $GWDefaults.AllowLaunchMethod.ToString()    
                                        $GWAllowAppsInNewTab          = $GWDefaults.AllowAppsInNewTab.ToString()    
                                        $GWUsePreWin2000LoginFormat   = $GWDefaults.UsePreWin2000LoginFormat.ToString()    
                                        $GWAllowEmbed                 = $GWDefaults.AllowEmbed.ToString()    
                                        $GWAllowFileTransfer          = $GWDefaults.AllowFileTransfer.ToString()    
                                        $GWAllowClipboard             = $GWDefaults.AllowClipboard.ToString()    
                                        $GWAllowCORS                  = $GWDefaults.AllowCORS    
                                        $GWAllowedDomainsForCORS      = $GWDefaults.AllowedDomainsForCORS    
                                        $GWBrowserCacheTimeInMonths   = $GWDefaults.BrowserCacheTimeInMonths    
                                        $GWEnableAlternateNLBHostname = $GWDefaults.EnableAlternateNLBHost.ToString()    
                                        $GWAlternameNLBHostname       = $GWDefaults.AlternateNLBHost    
                                        $GWEnableAlternateNLBPort     = $GWDefaults.EnableAlternateNLBPort.ToString()    
                                        $GWAlternateNLBPort           = $GWDefaults.AlternateNLBPort.ToString()    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $GWEnableHTML5Client          = "True"    
                                        $GWLaunchSessionsUsing        = "Launch apps with Parallels CLient & Fallback to HTML5"    
                                        $GWAllowLaunchMethod          = "True"    
                                        $GWAllowAppsInNewTab          = "False"    
                                        $GWUsePreWin2000LoginFormat   = "True"    
                                        $GWAllowEmbed                 = "False"    
                                        $GWAllowFileTransfer          = "True"    
                                        $GWAllowClipboard             = "True"    
                                        $GWAllowCORS                  = "False"    
                                        $GWAllowedDomainsForCORS      = @()    
                                        $GWBrowserCacheTimeInMonths   = 12    
                                        $GWEnableAlternateNLBHostname = "False"    
                                        $GWAlternameNLBHostname       = ""    
                                        $GWEnableAlternateNLBPort     = "False"    
                                        $GWAlternateNLBPort           = "8443"    
                                        $GWClipboardTransferMode      = "Bidirectional"    
                                        $GWClipboardTransferMode      = "Bidirectional"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                $GWEnableHTML5Client = $GW.EnableHTML5.ToString()    
                                    
                                Switch($GW.LaunchMethod)    
                                {    
                                        "ParallelsClientAndHTML5"       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break}    
                                        "ParallelsClient"                       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client"; Break}    
                                        "HTML5"                                         {$GWLaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break}    
                                        Default                                         {$GWLaunchSessionsUsing = "Unable to determine Launch sessions using: $($GW.LaunchMethod)"; Break}    
                                }    
                                    
                                Switch ($GW.FileTransferMode)    
                                {    
                                        "Bidirectional"         {$GWFileTransferMode = "Bidirectional"; Break}    
                                        "Disabled"                      {$GWFileTransferMode = "Disabled"; Break}    
                                        "ClientToServer"        {$GWFileTransferMode = "Client to server only"; Break}    
                                        "ServerToClient"        {$GWFileTransferMode = "Server to client only"; Break}    
                                        Default                         {$GWFileTransferMode = "Unable to determine File Transfer mode: $($GW.FileTransferMode)"; Break}    
                                }    
     
                                Switch ($GW.ClipboardDirection)    
                                {    
                                        "Bidirectional"         {$GWClipboardTransferMode = "Bidirectional"; Break}    
                                        "Disabled"                      {$GWClipboardTransferMode = "Disabled"; Break}    
                                        "ClientToServer"        {$GWClipboardTransferMode = "Client to server only"; Break}    
                                        "ServerToClient"        {$GWClipboardTransferMode = "Server to client only"; Break}    
                                        Default                         {$GWClipboardTransferMode = "Unable to determine Clipboard mode: $($GW.ClipboardDirection)"; Break}    
                                }    
     
                                $GWAllowLaunchMethod          = $GW.AllowLaunchMethod.ToString()    
                                $GWAllowAppsInNewTab          = $GW.AllowAppsInNewTab.ToString()    
                                $GWUsePreWin2000LoginFormat   = $GW.UsePreWin2000LoginFormat.ToString()    
                                $GWAllowEmbed                 = $GW.AllowEmbed.ToString()    
                                $GWAllowFileTransfer          = $GW.AllowFileTransfer    
                                $GWAllowClipboard             = $GW.AllowClipboard    
                                $GWAllowCORS                  = $GW.AllowCORS    
                                $GWAllowedDomainsForCORS      = $GW.AllowedDomainsForCORS    
                                $GWBrowserCacheTimeInMonths   = $GW.BrowserCacheTimeInMonths    
                                $GWEnableAlternateNLBHostname = $GW.EnableAlternateNLBHost.ToString()    
                                $GWAlternameNLBHostname       = $GW.AlternateNLBHost    
                                $GWEnableAlternateNLBPort     = $GW.EnableAlternateNLBPort.ToString()    
                                $GWAlternateNLBPort           = $GW.AlternateNLBPort.ToString()    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultHTML5Settings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable HTML5 Client"; Value = $GWEnableHTML5Client; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Client"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $GWLaunchSessionsUsing; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $GWAllowLaunchMethod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $GWAllowAppsInNewTab; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $GWUsePreWin2000LoginFormat; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow embedding of Parallels HTML5 Client into other web pages"; Value = $GWAllowEmbed; }) > $Null    
     
                                $ScriptInformation.Add(@{Data = "     Allow file transfer command"; Value = $GWAllowFileTransfer.ToString(); }) > $Null    
                                If($GWAllowFileTransfer)    
                                {    
                                        $ScriptInformation.Add(@{Data = "          Direction"; Value = $GWFileTransferMode; }) > $Null    
                                }    
     
                                $ScriptInformation.Add(@{Data = "     Allow clipboard command"; Value = $GWAllowClipboard.ToString(); }) > $Null    
                                If($GWAllowClipboard)    
                                {    
                                        $ScriptInformation.Add(@{Data = "          Clipboard Redirection"; Value = $GWClipboardTransferMode; }) > $Null    
                                }    
     
                                $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $GWAllowCORS.ToString(); }) > $Null    
                                If($GWAllowCORS)    
                                {    
                                        $cnt=-1    
                                        ForEach($Domain in $GWAllowedDomainsForCORS)    
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "     Allow domains"; Value = $Domain; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $Domain; }) > $Null    
                                                }    
                                        }    
                                        $ScriptInformation.Add(@{Data = "     Browser cache time"; Value = "$($GWBrowserCacheTimeInMonths.ToString()) months"; }) > $Null    
                                }    
     
                                $ScriptInformation.Add(@{Data = "Network Load Balancer access"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Use alternate hostname"; Value = $GWEnableAlternateNLBHostname; }) > $Null    
                                If($GWEnableAlternateNLBHostname -eq "True")    
                                {    
                                        $ScriptInformation.Add(@{Data = ""; Value = $GWAlternameNLBHostname; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "     Use alternate port"; Value = $GWEnableAlternateNLBPort; }) > $Null    
                                If($GWEnableAlternateNLBPort -eq "True")    
                                {    
                                        $ScriptInformation.Add(@{Data = ""; Value = $GWAlternateNLBPort; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t`t`t: " $GW.InheritDefaultHTML5Settings.ToString()    
                                Line 3 "Enable HTML5 Client`t`t`t`t: " $GWEnableHTML5Client    
                                Line 3 "Client" ""    
                                Line 4 "Launch sessions using`t`t`t: " $GWLaunchSessionsUsing    
                                Line 4 "Allow user to select a launch method`t: " $GWAllowLaunchMethod    
                                Line 4 "Allow opening applications in a new tab`t: " $GWAllowAppsInNewTab    
                                Line 4 "Use Pre Windows 2000 login format`t: " $GWUsePreWin2000LoginFormat    
                                Line 4 "Allow embedding of Parallels HTML5"    
                                Line 4 "Client into other web pages`t`t: " $GWAllowEmbed    
     
                                Line 4 "Allow file transfer command`t`t: " $GWAllowFileTransfer.ToString()    
                                If($GW.AllowFileTransfer)    
                                {    
                                        Line 5 "Direction: " $GWFileTransferMode    
                                }    
     
                                Line 4 "Allow clipboard command`t`t`t: " $GWAllowClipboard.ToString()    
                                If($GW.AllowClipboard)    
                                {    
                                        Line 5 "Clipboard Redirection: " $GWClipboardTransferMode    
                                }    
     
                                Line 4 "Allow cross-origin resource sharing`t: " $GWAllowCORS.ToString()    
                                If($GWAllowCORS)    
                                {    
                                        $cnt=-1    
                                        ForEach($Domain in $GWAllowedDomainsForCORS)    
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 7 "Allow domains   : " $Domain    
                                                }    
                                                Else    
                                                {    
                                                        Line 9 "  " $Domain    
                                                }    
                                        }    
                                        Line 6 "Browser cache time      : " "$($GWBrowserCacheTimeInMonths.ToString()) months"    
                                }    
     
                                Line 3 "Network Load Balancer access" ""    
                                Line 4 "Use alternate hostname`t`t: " $GWEnableAlternateNLBHostname    
                                If($GWEnableAlternateNLBHostname -eq "True")    
                                {    
                                        Line 8 $GWAlternameNLBHostname    
                                }    
                                Line 4 "Use alternate port`t`t: " $GWEnableAlternateNLBPort    
                                If($GWEnableAlternateNLBPort -eq "True")    
                                {    
                                        Line 8 $GWAlternateNLBPort    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultHTML5Settings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Enable HTML5 Client",($Script:htmlsb),$GWEnableHTML5Client,$htmlwhite))    
                                $rowdata += @(,("Client",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$GWLaunchSessionsUsing,$htmlwhite))    
                                $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$GWAllowLaunchMethod,$htmlwhite))    
                                $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb),$GWAllowAppsInNewTab,$htmlwhite))    
                                $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb),$GWUsePreWin2000LoginFormat,$htmlwhite))    
                                $rowdata += @(,("     Allow embedding of Parallels HTML5 Client into other web pages",($Script:htmlsb),$GWAllowEmbed,$htmlwhite))    
     
                                $rowdata += @(,("     Allow file transfer command",($Script:htmlsb),$GWAllowFileTransfer.ToString(),$htmlwhite))    
                                If($GW.AllowFileTransfer)    
                                {    
                                        $rowdata += @(,("          Direction",($Script:htmlsb),$GWFileTransferMode,$htmlwhite))    
                                }    
     
                                $rowdata += @(,("     Allow clipboard command",($Script:htmlsb),$GWAllowClipboard.ToString(),$htmlwhite))    
                                If($GW.AllowClipboard)    
                                {    
                                        $rowdata += @(,("          Clipboard Redirection",($Script:htmlsb),$GWClipboardTransferMode,$htmlwhite))    
                                }    
     
                                $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$GWAllowCORS.ToString(),$htmlwhite))    
                                If($GWAllowCORS)    
                                {    
                                        $cnt=-1    
                                        ForEach($Domain in $GWAllowedDomainsForCORS)    
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("     Allow domains",($Script:htmlsb),$Domain,$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$Domain,$htmlwhite))    
                                                }    
                                        }    
                                        $rowdata += @(,("     Browser cache time",($Script:htmlsb),"$($GWBrowserCacheTimeInMonths.ToString()) months",$htmlwhite))    
                                }    
     
                                $rowdata += @(,("Network Load Balancer access",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("     Use alternate hostname",($Script:htmlsb),$GWEnableAlternateNLBHostname,$htmlwhite))    
                                If($GWEnableAlternateNLBHostname -eq "True")    
                                {    
                                        $rowdata += @(,("",($Script:htmlsb),$GWAlternameNLBHostname,$htmlwhite))    
                                }    
                                $rowdata += @(,("     Use alternate port",($Script:htmlsb),$GWEnableAlternateNLBPort,$htmlwhite))    
                                If($GWEnableAlternateNLBPort -eq "True")    
                                {    
                                        $rowdata += @(,("",($Script:htmlsb),$GWAlternateNLBPort,$htmlwhite))    
                                }    
     
                                $msg = "HTML5"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Wyse    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Wyse"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Wyse"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($GW.InheritDefaultWyseSettings)    
                        {    
                                #do we inherit site defaults?    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
     
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
                                {    
                                        $GWEnableWyse          = $GWDefaults.EnableWyseSupport.ToString()    
                                        $GWDisableWyseCertWarn = $GWDefaults.DisableWyseCertWarn.ToString()    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $GWEnableWyse          = "True"    
                                        $GWDisableWyseCertWarn = "False"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                $GWEnableWyse          = $GW.EnableWyseSupport.ToString()    
                                $GWDisableWyseCertWarn = $GW.DisableWyseCertWarn.ToString()    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultWyseSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable Wyse ThinOS Support"; Value = $GWEnableWyse; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Do not warn if server certificate is not verified"; Value = $GWDisableWyseCertWarn; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t`t`t : " $GW.InheritDefaultWyseSettings.ToString()    
                                Line 3 "Enable Wyse ThinOS Support`t`t`t : " $GWEnableWyse    
                                Line 3 "Do not warn if server certificate is not verified: " $GWDisableWyseCertWarn    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultWyseSettings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Enable Wyse ThinOS Support",($Script:htmlsb),$GWEnableWyse,$htmlwhite))    
                                $rowdata += @(,("Do not warn if server certificate is not verified",($Script:htmlsb),$GWDisableWyseCertWarn,$htmlwhite))    
     
                                $msg = "Wyse"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Security    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Security"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Security"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($GW.InheritDefaultSecuritySettings)    
                        {    
                                #do we inherit site defaults?    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
     
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
                                {    
                                        If($GWDefaults.SecurityMode -eq "AllowAllExcept")    
                                        {    
                                                $GWAllow = "AllowAllExcept"    
                                                $MACAddresses = @()    
                                                ForEach($Item in $GWDefaults.MACAllowExcept)    
                                                {    
                                                        $MACAddresses += $Item    
                                                }    
                                        }    
                                        Else    
                                        {    
                                                $GWAllow = "AllowOnly"    
                                                $MACAddresses = @()    
                                                ForEach($Item in $GWDefaults.MACAllowOnly)    
                                                {    
                                                        $MACAddresses += $Item    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $GWAllow = "AllowAllExcept"    
                                        $MACAddresses = @()    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                If($GW.SecurityMode -eq "AllowAllExcept")    
                                {    
                                        $GWAllow = "AllowAllExcept"    
                                        $MACAddresses = @()    
                                        ForEach($Item in $GW.MACAllowExcept)    
                                        {    
                                                $MACAddresses += $Item    
                                        }    
                                }    
                                Else    
                                {    
                                        $GWAllow = "AllowOnly"    
                                        $MACAddresses = @()    
                                        ForEach($Item in $GW.MACAllowOnly)    
                                        {    
                                                $MACAddresses += $Item    
                                        }    
                                }    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultSecuritySettings.ToString(); }) > $Null    
                                If($GWAllow -eq "AllowAllExcept")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Allow all except"; Value = ""; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Allow only"; Value = ""; }) > $Null    
                                }    
                                $cnt =-1    
                                ForEach($Item in $MACAddresses)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "MAC Address"; Value = $Item; }) > $Null    
 
                                Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultSecuritySettings.ToString() <>                                 Line 3 "Enable Schedule`t`t`t: " $RDSSchedule.Enabled.ToString()
                                If($GWAllow -eq "AllowAllExcept")                                   Line 3 "Name`t`t`t`t: " $RDSSchedule.Name
                                {                                   Line 3 "Action`t`t`t`t: " $Action
                                        Line 3 "Allow all except"                                   Line 3 "Description`t`t`t: " $RDSSchedule.Description
                                }                                  
                                Else    
                                {    
                                        Line 3 "Allow only"    
                                }    
                                $cnt =-1                                   $cnt=-1
                                ForEach($Item in $MACAddresses)                                   ForEach($Item in $Target)
 
                                                Line 3 "MAC Address`t`t`t`t: " $Item <>                                                 Line 3 "Target`t`t`t`t: " $Item
 
                                                Line 8 "  " $Item <>                                                 Line 7 "  " $Item
 
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultSecuritySettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Enable schedule",($Script:htmlsb),$RDSSchedule.Enabled.ToString(),$htmlwhite)
                                If($GWAllow -eq "AllowAllExcept")    
                                {    
                                        $rowdata += @(,("Allow all except",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite))
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Allow only",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))
                                }                                  
                                $cnt =-1                                   $cnt=-1
                                ForEach($Item in $MACAddresses)                                   ForEach($Item in $Target)
 
                                                $rowdata += @(,("MAC Address",($Script:htmlsb),$Item,$htmlwhite)) <>                                                 $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))
 
  <>                                 
                                $msg = "Security"                                   $msg = "General"
                                $columnWidths = @("300","275")                                   $columnWidths = @("200","275")
 
                        #Web <>                         #Trigger
 
                                WriteWordLine 4 0 "Web" <>                                 WriteWordLine 4 0 "Trigger"
 
                                Line 2 "Web" <>                                 Line 2 "Trigger"
 
                        If($GW.InheritDefaultWebSettings) <>                         If($MSWord -or $PDF)
 
                                #do we inherit site defaults? <>                                 $ScriptInformation = New-Object System.Collections.ArrayList
                                #yes we do, get the default settings for the Site                                   $ScriptInformation.Add(@{Data = "Date"; Value = $RDSSchedule.StartDateTime.ToShortDateString(); }) > $Null
                                #use the Site default settings                                   $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime.ToShortTimeString(); }) > $Null
                                    <#If($Action -eq "Reboot - Drain Mode")
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
 
                                        $GWDefaultURL = $GWDefaults.WebRequestsURL <>                                         $ScriptInformation.Add(@{Data = "Complete in"; Value = $TimeDuration  ; }) > $Null
                                        $GWWebCookie = $GWDefaults.WebCookie    
 
                                Else <>                                 ElseIf($Action -eq "Disable")
 
                                        #unable to retrieve default, use built-in default values <>  
                                        $GWDefaultURL = "https://%hostname%/RASHTML5Gateway"    
                                        $GWWebCookie = "ASP.NET_SessionId"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                $GWDefaultURL = $GW.WebRequestsURL    
                                $GWWebCookie = $GW.WebCookie    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultWebSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Default URL"; Value = $GWDefaultURL; }) > $Null                                           $ScriptInformation.Add(@{Data = "Duration"; Value = $TimeDuration; }) > $Null
                                    }#>
                                $ScriptInformation.Add(@{Data = "Web cookie"; Value = $GWWebCookie; }) > $Null                                   $ScriptInformation.Add(@{Data = "Recur"; Value = $Repeat; }) > $Null
 
                                Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultWebSettings.ToString() <>                                 Line 3 "Date`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortDateString()
                                Line 3 "Default URL`t`t`t`t: " $GWDefaultURL                                   Line 3 "Start`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortTimeString()
                                Line 3 "Web cookie`t`t`t`t: " $GWWebCookie                                   <#If($Action -eq "Reboot - Drain Mode")
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {                                   {
                                $rowdata = @()                                           Line 3 "Complete in`t`t`t: " $TimeDuration
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultWebSettings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Default URL",($Script:htmlsb),$GWDefaultURL,$htmlwhite))    
                                $rowdata += @(,("Web cookie",($Script:htmlsb),$GWWebCookie,$htmlwhite))    
     
                                $msg = "Web"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }                                   }
                }                                   ElseIf($Action -eq "Disable")
        }    
     
        $PAs = Get-RASPA -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {                                   {
                Write-Warning "                                           Line 3 "Duration`t`t`t: " $TimeDuration
                `n    
                Unable to retrieve Publishing Agents for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"    
                }                                   }#>
                If($Text)                                   Line 3 "Recur`t`t`t`t: " $Repeat
                {                                   Line 0 ""
                        Line 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"    
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"                                   $rowdata = @()
                }                                   $columnHeaders = @("Date",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortDateString(),$htmlwhite)
        }                                   $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortTimeString(),$htmlwhite))
        ElseIf($? -and $Null -eq $PAs)                                   <#If($Action -eq "Reboot - Drain Mode")
        {                                   {
                Write-Host "                                           $rowdata += @(,("Complete in",($Script:htmlsb),$TimeDuration,$htmlwhite))
                No Publishing Agents retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)"    
                }                                   }
                If($Text)                                   ElseIf($Action -eq "Disable")
                {                                   {
                        Line 0 "No Publishing Agents retrieved for Site $($Site.Name)"                                           $rowdata += @(,("Duration",($Script:htmlsb),$TimeDuration,$htmlwhite))
                }                                   }#>
                If($HTML)                                   $rowdata += @(,("Recur",($Script:htmlsb),$Repeat,$htmlwhite))
                {    
                        WriteHTMLLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)"                                   $msg = "Trigger"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                }                           }
        }    
        Else                           #Options
        {                           
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 2 0 "Publishing Agents"                                   WriteWordLine 4 0 "Options"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 1 "Publishing Agents"                                   Line 2 "Options"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 2 0 "Publishing Agents"                                   #Nothing
                }                           }
     
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Publishing Agents"    
                ForEach($PA in $PAs)    
                {    
                        $PAStatus = Get-RASPAStatus -Id $PA.Id -EA 0 4>$Null    
 
                        If(!$?) <>  
                        {    
                                Write-Warning "    
                                `n    
                                Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)`    
                                "    
                                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                                {                           {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                        WriteWordLine 0 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)"                                   $ScriptInformation.Add(@{Data = "Send message before schedule is triggered"; Value = ""; }) > $Null
                                }    
                                If($Text)                                   If($RDSSChedule.Messages.Count -gt 0)
 
                                        Line 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)" <>                                         ForEach($Item in $RDSSChedule.Messages)
                                }                                           {
                                If($HTML)                                                   Switch ($Item.SendMsgSecs)
                                {                                                   {
                                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)"                                                           900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}
                                                            1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}
                                                            2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}
                                                            3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}
                                                            7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}
                                                            10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}
                                                            Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}
                                }                                                   }
                                                    
                                                    $ScriptInformation.Add(@{Data = "Enabled"; Value = $Item.Enabled.ToString(); }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Body"; Value = $Item.Message; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Title"; Value = $Item.MessageTitle; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Time"; Value = $MsgTime; }) > $Null
                        }                                           }
                        ElseIf($? -and $Null -eq $PAStatus)    
                        {    
                                Write-Host "    
                                No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)"    
 
                                If($Text) <>  
                                    If($Action -ne "Disable")
 
                                        Line 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)" <>                                         $ScriptInformation.Add(@{Data = "Enable Drain Mode"; Value = $RDSSchedule.DrainMode.ToString(); }) > $Null
 
                                If($HTML) <>                                 <#If($Action -eq "Reboot - Drain Mode")
 
                                        WriteHTMLLine 0 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)" <>                                         $ScriptInformation.Add(@{Data = "Force server reboot after"; Value = $ForceRebootTime; }) > $Null
                                }                                   }#>
                        }                                   If($Action -like "Reboot*")
                        Else    
                        {    
                                If($PA.Standby -eq $False)    
 
                                        $PAPriority = "Master" <>                                         $ScriptInformation.Add(@{Data = "Enforce schedule for currently inactive RD Session Host"; Value = $RDSSchedule.EnforceOnInactive.ToString(); }) > $Null
 
                                Else <>                                 If($Action -eq "Disable")
 
                                        $PAPriority = "Standby" <>                                         $ScriptInformation.Add(@{Data = "On disable"; Value = $OnDisable; }) > $Null
 
  +-  
                                $PAStatusAgentState = GetRASStatus $PAStatus.AgentState    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 3 0 "Publishing Agents $($PA.Server)"    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Server"; Value = $PA.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Priority"; Value = $PAPriority; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $PAStatusAgentState; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Log level"; Value = $PAStatus.LogLevel; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PA.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $PA.TimeLastMod.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $PA.AdminCreate; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $PA.TimeCreate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $PA.Id.ToString(); }) > $Null    
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                        -Columns Data,Value `                                   -Columns Data,Value `
                                        -List `                                   -List `
                                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                                        $Table = $Null                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                }                           }
                                If($Text)                           If($Text)
                                {                           {
                                        Line 2 "Publishing Agents $($PA.Server)"                                   Line 3 "Send message before schedule is triggered"
                                    
                                    If($RDSSChedule.Messages.Count -gt 0)
                                    {
                                            ForEach($Item in $RDSSChedule.Messages)
                                            {
                                                    Switch ($Item.SendMsgSecs)
                                                    {
                                                            900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}
                                                            1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}
                                                            2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}
                                                            3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}
                                                            7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}
                                                            10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}
                                                            Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}
                                                    }
                                                    
                                                    Line 3 "Enabled`t`t`t`t: " $Item.Enabled.ToString()
                                        Line 3 "Server`t`t`t: " $PA.Server                                                   Line 3 "Body`t`t`t`t: " $Item.Message
                                        Line 3 "Priority`t`t: " $PAPriority    
                                        Line 3 "Status`t`t`t: " $PAStatusAgentState                                                   Line 3 "Title`t`t`t`t: " $Item.MessageTitle
                                                    Line 3 "Time`t`t`t`t: " $MsgTime
                                            }
                                    }
     
                                    If($Action -ne "Disable")
                                    {
                                            Line 3 "Enable Drain Mode`t`t: " $RDSSchedule.DrainMode.ToString()
                                    }
                                    <#If($Action -eq "Reboot - Drain Mode")
                                    {
                                            Line 3 "Force server reboot after`t: " $ForceRebootTime
                                    }#>
                                    If($Action -like "Reboot*")
                                    {
                                            Line 3 "Enforce schedule for currently"
                                            Line 3 "inactive RD Session Host`t: " $RDSSchedule.EnforceOnInactive.ToString()
                                    }
                                    If($Action -eq "Disable")
                                    {
                                            Line 3 "On disable`t`t`t: " $OnDisable
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Send message before schedule is triggered",($Script:htmlsb),"",$htmlwhite)
                                    
                                    If($RDSSChedule.Messages.Count -gt 0)
                                    {
                                            ForEach($Item in $RDSSChedule.Messages)
                                            {
                                                    Switch ($Item.SendMsgSecs)
                                                    {
                                                            900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}
                                                            1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}
                                                            2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}
                                                            3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}
                                                            7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}
                                                            10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}
                                                            Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}
                                                    }
                                                    
                                                    $rowdata += @(,("Enabled",($Script:htmlsb),$Item.Enabled.ToString(),$htmlwhite))
                                                    $rowdata += @(,("Body",($Script:htmlsb),$Item.Message,$htmlwhite))
                                                    $rowdata += @(,("Title",($Script:htmlsb),$Item.MessageTitle,$htmlwhite))
                                                    $rowdata += @(,("Time",($Script:htmlsb),$MsgTime,$htmlwhite))
                                            }
                                    }
     
                                    If($Action -ne "Disable")
                                    {
                                            $rowdata += @(,("Enable Drain Mode",($Script:htmlsb),$RDSSchedule.DrainMode.ToString(),$htmlwhite))
                                    }
                                    <#If($Action -eq "Reboot - Drain Mode")
                                    {
                                            $rowdata += @(,("Force server reboot after",($Script:htmlsb),$ForceRebootTime,$htmlwhite))
                                    }#>
                                    If($Action -like "Reboot*")
                                    {
                                            $rowdata += @(,("Enforce schedule for currently inactive RD Session Host",($Script:htmlsb),$RDSSchedule.EnforceOnInactive.ToString(),$htmlwhite))
                                    }
                                    If($Action -eq "Disable")
                                    {
                                            $rowdata += @(,("On disable",($Script:htmlsb),$OnDisable,$htmlwhite))
                                    }
     
                                    $msg = "Options"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
     
            #VDI
            $VDIHosts = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve VDI for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve VDI for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $VDIHosts)
            {
                    Write-Host "
                    No VDI retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No VDI retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No VDI retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No VDI retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "VDI"
                    }
                    If($Text)
                    {
                            Line 1 "VDI"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "VDI"
                    }
     
                    #Pools
                    
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 3 0 "Pools"
                    }
                    If($Text)
                    {
                            Line 2 "Pools"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 3 0 "Pools"
                    }
                    
                    If($MSWord -or $PDF)
                    {
                            $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null
                            If($? -and $Null -ne $VDIPools)
                            {
                                    ForEach($VDIPool in $VDIPools)
                                    {
                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null 
                                            
                                            If($? -and $Null -ne $VDIPoolMembers)
                                            {
                                                    $VDIPoolMember = $VDIPoolMembers[0]
                                                    Switch($VDIPoolMember.Type)
                                                    {
                                                            "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                            "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                            "Desktop"                               {$MemberType = "Guest"; Break}
                                                            "GUEST"                                 {$MemberType = "Guest"; Break}
                                                            "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                            "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                            "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                            "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                            Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                    }
                                            }
                                            Else
                                            {
                                                    $MemberType = ""
                                            }
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Name"; Value = $VDIPool.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Enabled"; Value = $VDIPool.Enabled.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $VDIPool.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Members type"; Value = $MemberType; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Last modification by"; Value = $VDIPool.AdminLastMod; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Modified on"; Value = $VDIPool.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created by"; Value = $VDIPool.AdminCreate; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created on"; Value = $VDIPool.TimeCreate.ToString(); }) > $Null
                                            
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                            
                                            #General
                                            
                                            WriteWordLine 4 0 "General"
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Enable pool in site"; Value = $VDIPool.Enabled.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Name"; Value = $VDIPool.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $VDIPool.Description; }) > $Null
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                            
                                            #Members
                                            
                                            WriteWordLine 4 0 "Members"
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            If($VDIPool.Members.Count -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Members"; Value = "There are no pool members"; }) > $Null
                                            }
                                            Else
                                            {
                                                    ForEach($Item in $VDIPool.Members)
                                                    {
                                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $VDIPoolMembers)
                                                            {
                                                                    ForEach($VDIPoolMember in $VDIPoolMembers)
                                                                    {
                                                                            Switch($VDIPoolMember.Type)
                                                                            {
                                                                                    "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                                                    "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                                                    "Desktop"                               {$MemberType = "Guest"; Break}
                                                                                    "GUEST"                                 {$MemberType = "Guest"; Break}
                                                                                    "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                                                    "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                                                    "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                                                    "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                                                    Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                                            }
                                                                            $ScriptInformation.Add(@{Data = "Name: $($VDIPoolMember.Name)"; Value = "Type: $MemberType"; }) > $Null
                                                                    }
                                                            }
                                                            ElseIf($? -and $Null -eq $VDIPoolMembers)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "Members"; Value = "None found"; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "Members"; Value = "Unable to retrieve"; }) > $Null
                                                            }
                                                    }
                                            }
     
                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "WildCard"; Value = $VDIPool.WildCard; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                            }
                            ElseIf($? -and $Null -eq $VDIPools)
                            {
                                    WriteWordLine 0 0 "No VDI Pools found for Site $($Site.Name)"
                            }
                            Else
                            {
                                    WriteWordLine 0 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"
                            }
                            WriteWordLine 0 0 ""
                    }
                    If($Text)
                    {
                            $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null
                            If($? -and $Null -ne $VDIPools)
                            {
                                    ForEach($VDIPool in $VDIPools)
                                    {
                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null 
                                            
                                            If($? -and $Null -ne $VDIPoolMembers)
                                            {
                                                    $VDIPoolMember = $VDIPoolMembers[0]
                                                    Switch($VDIPoolMember.Type)
                                                    {
                                                            "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                            "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                            "Desktop"                               {$MemberType = "Guest"; Break}
                                                            "GUEST"                                 {$MemberType = "Guest"; Break}
                                                            "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                            "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                            "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                            "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                            Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                    }
                                            }
                                            Else
                                            {
                                                    $MemberType = ""
                                            }
     
                                        Line 3 "Log level`t`t: " $PAStatus.LogLevel                                           Line 3 "Name`t`t`t: " $VDIPool.Name
                                            Line 3 "Enabled`t`t`t: " $VDIPool.Enabled.ToString()
                                            Line 3 "Description`t`t: " $VDIPool.Description
                                            Line 3 "Members type`t`t: " $MemberType
                                        Line 3 "Last modification by`t: " $PA.AdminLastMod                                           Line 3 "Last modification by`t: " $VDIPool.AdminLastMod
                                        Line 3 "Modified on`t`t: " $PA.TimeLastMod.ToString()                                           Line 3 "Modified on`t`t: " $VDIPool.TimeLastMod.ToString()
                                        Line 3 "Created by`t`t: " $PA.AdminCreate                                           Line 3 "Created by`t`t: " $VDIPool.AdminCreate
                                        Line 3 "Created on`t`t: " $PA.TimeCreate.ToString()                                           Line 3 "Created on`t`t: " $VDIPool.TimeCreate.ToString()
                                            Line 0 ""
                                            
                                            #General
                                            Line 3 "General"
                                        Line 3 "ID`t`t`t: " $PA.Id.ToString()                                           Line 4 "Enable pool in site`t: " $VDIPool.Enabled.ToString()
                                            Line 4 "Name`t`t`t: " $VDIPool.Name
                                            Line 4 "Description`t`t: " $VDIPool.Description
 
  -+                                         
                                            #Members
                                            
                                            Line 3 "Members"
                                            If($VDIPool.Members.Count -eq 0)
                                            {
                                                    Line 4 "Members: " "There are no pool members"
                                            }
                                            Else
                                            {
                                                    ForEach($Item in $VDIPool.Members)
                                                    {
                                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $VDIPoolMembers)
                                                            {
                                                                    ForEach($VDIPoolMember in $VDIPoolMembers)
                                                                    {
                                                                            Switch($VDIPoolMember.Type)
                                                                            {
                                                                                    "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                                                    "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                                                    "Desktop"                               {$MemberType = "Guest"; Break}
                                                                                    "GUEST"                                 {$MemberType = "Guest"; Break}
                                                                                    "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                                                    "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                                                    "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                                                    "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                                                    Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                                            }
                                                                            Line 4 "Name: $($VDIPoolMember.Name) " "Type: $MemberType"
                                                                    }
                                                            }
                                                            ElseIf($? -and $Null -eq $VDIPoolMembers)
                                                            {
                                                                    Line 4 "Members: " "None found"
                                                            }
                                                            Else
                                                            {
                                                                    Line 4 "Members: " "Unable to retrieve"
                                                            }
                                                    }
                                            }
                                            Line 0 ""
                                            Line 4 "WildCard: " $VDIPool.WildCard
                                            Line 0 ""
 
  <>                                 Line 0 ""
                            }
                            ElseIf($? -and $Null -eq $VDIPools)
                            {
                                    Line 0 "No VDI Pools found for Site $($Site.Name)"
                            }
                            Else
                            {
                                    Line 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"
                            }
                            Line 0 ""
                    }
                                If($HTML)                   If($HTML)
                    {
                            $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null
                            If($? -and $Null -ne $VDIPools)
                            {
                                    ForEach($VDIPool in $VDIPools)
 
                                        WriteHTMLLine 3 0 "Publishing Agents $($PA.Server)" <>                                         $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null 
                                            
                                            If($? -and $Null -ne $VDIPoolMembers)
                                            {
                                                    $VDIPoolMember = $VDIPoolMembers[0]
                                                    Switch($VDIPoolMember.Type)
                                                    {
                                                            "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                            "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                            "Desktop"                               {$MemberType = "Guest"; Break}
                                                            "GUEST"                                 {$MemberType = "Guest"; Break}
                                                            "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                            "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                            "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                            "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                            Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                    }
                                            }
                                            Else
                                            {
                                                    $MemberType = ""
                                            }
     
 
                                        $columnHeaders = @("Server",($Script:htmlsb),$PA.Server,$htmlwhite) <>                                         $columnHeaders = @("Name",($Script:htmlsb),$VDIPool.Name,$htmlwhite)
                                        $rowdata += @(,("Priority",($Script:htmlsb),$PAPriority,$htmlwhite))                                           $rowdata += @(,("Enabled",($Script:htmlsb),$VDIPool.Enabled.ToString(),$htmlwhite))
                                        $rowdata += @(,("Status",($Script:htmlsb),$PAStatusAgentState,$htmlwhite))                                           $rowdata += @(,("Description",($Script:htmlsb),$VDIPool.Description,$htmlwhite))
                                        $rowdata += @(,("Log level",($Script:htmlsb),$PAStatus.LogLevel,$htmlwhite))                                           $rowdata += @(,("Members type: ",($Script:htmlsb),$MemberType,$htmlwhite))
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $PA.AdminLastMod,$htmlwhite))                                           $rowdata += @(,("Last modification by",($Script:htmlsb), $VDIPool.AdminLastMod,$htmlwhite))
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $PA.TimeLastMod.ToString(),$htmlwhite))                                           $rowdata += @(,("Modified on",($Script:htmlsb), $VDIPool.TimeLastMod.ToString(),$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $PA.AdminCreate,$htmlwhite))                                           $rowdata += @(,("Created by",($Script:htmlsb), $VDIPool.AdminCreate,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $PA.TimeCreate.ToString(),$htmlwhite))                                           $rowdata += @(,("Created on",($Script:htmlsb), $VDIPool.TimeCreate.ToString(),$htmlwhite))
                                            
                                            ForEach($Item in $VDIPool.Members)
                                            {
                                                    $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null
                                                    
                                                    If($? -and $Null -ne $VDIPoolMembers)
                                                    {
                                                            $cnt = -1
                                                            ForEach($VDIPoolMember in $VDIPoolMembers)
                                                            {
                                                                    Switch($VDIPoolMember.Type)
                                                                    {
                                                                            "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                                            "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                                            "Desktop"                               {$MemberType = "Guest"; Break}
                                                                            "GUEST"                                 {$MemberType = "Guest"; Break}
                                                                            "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                                            "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                                            "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                                            "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                                            Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                                    }
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("    Members",($Script:htmlsb),"Name: $($VDIPoolMember.Name) Type: $MemberType",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb),"Name: $($VDIPoolMember.Name) Type: $MemberType",$htmlwhite))
                                                                    }
                                                            }
                                                    }
                                                    ElseIf($? -and $Null -eq $VDIPoolMembers)
                                                    {
                                        $rowdata += @(,("ID",($Script:htmlsb),$PA.Id.ToString(),$htmlwhite))                                                           $rowdata += @(,("    Members",($Script:htmlsb),"None found",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("    Members",($Script:htmlsb),"Unable to retrieve",$htmlwhite))
                                                    }
                                            }
 
  -+  
                                            #General
                                    
                                            $rowdata = @()
                                            $columnHeaders = @("Enable pool in site",($Script:htmlsb),$VDIPool.Enabled.ToString(),$htmlwhite)
                                            $rowdata += @(,("Name",($Script:htmlsb),$VDIPool.Name,$htmlwhite))
                                            $rowdata += @(,("Description",($Script:htmlsb),$VDIPool.Description,$htmlwhite))
                                            
                                            $msg = "General"
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
     
                                            #Members
                            
                                            $rowdata = @()
                                            If($VDIPool.Members.Count -eq 0)
                                            {
                                                    $columnHeaders = @("Members",($Script:htmlsb),"There are no pool members",$htmlwhite)
                                            }
                                            Else
                                            {
                                                    ForEach($Item in $VDIPool.Members)
                                                    {
                                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $VDIPoolMembers)
                                                            {
                                                                    $cnt = -1
                                                                    ForEach($VDIPoolMember in $VDIPoolMembers)
                                                                    {
                                                                            Switch($VDIPoolMember.Type)
                                                                            {
                                                                                    "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                                                    "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                                                    "Desktop"                               {$MemberType = "Guest"; Break}
                                                                                    "GUEST"                                 {$MemberType = "Guest"; Break}
                                                                                    "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                                                    "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                                                    "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                                                    "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                                                    Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                                            }
                                                                            $cnt++
                                                                            If($cnt -eq 0)
                                                                            {
                                                                                    $columnHeaders = @("Name: $($VDIPoolMember.Name)",($Script:htmlsb),"Type: $MemberType",$htmlwhite)
                                                                            }
                                                                            Else
                                                                            {
                                                                                    $rowdata += @(,("Name: $($VDIPoolMember.Name)",($Script:htmlsb),"Type: $MemberType",$htmlwhite))
                                                                            }
                                                                    }
                                                            }
                                                            ElseIf($? -and $Null -eq $VDIPoolMembers)
                                                            {
                                                                    $rowdata += @(,("Members",($Script:htmlsb),"None found",$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("Members",($Script:htmlsb),"Unable to retrieve",$htmlwhite))
                                                            }
                                                    }
                                            }
                                            
                                            $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("WildCard",($Script:htmlsb),$VDIPool.WildCard,$htmlwhite))
     
                                            $msg = "Members"
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
 
  <>                         ElseIf($? -and $Null -eq $VDIPools)
                            {
                                    WriteHTMLLine 0 0 "No VDI Pools found for Site $($Site.Name)"
                            }
                            Else
                            {
                                    WriteHTMLLine 0 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"
                            }
                            WriteHTMLLine 0 0 ""
                    }
                                          
                    #Templates
                    
                        If($MSWord -or $PDF)                   If($MSWord -or $PDF)
                        {                   {
                                WriteWordLine 4 0 "Properties"                           WriteWordLine 3 0 "Templates"
                        }                   }
                        If($Text)                   If($Text)
                        {                   {
                                Line 2 "Properties"                           Line 2 "Templates"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 3 0 "Templates"
                    }
                    
                    $VDITemplates = Get-RASVDITemplate -SiteId $Site.Id -EA 0  | Where-Object {$_.TemplateType -eq "VDIDesktop"}
                    If(!$?)
                    {
                            Write-Warning "
                            `n
                            Unable to retrieve VDI Templates for Site $($Site.Name)`
                            "
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"
 
  -+                         If($Text)
                            {
                                    Line 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"
                            }
 
  <>                                 WriteHTMLLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"
                            }
                    }
                    ElseIf($? -and $Null -eq $VDITemplates)
                    {
                            Write-Host "
                            No VDI Templates retrieved for Site $($Site.Name).`
                            " -ForegroundColor White
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 0 0 "No VDI Templates retrieved for Site $($Site.Name)"
                            }
                            If($Text)
                            {
                                    Line 0 "No VDI Templates retrieved for Site $($Site.Name)"
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 0 0 "No VDI Templates retrieved for Site $($Site.Name)"
                            }
                    }
                    Else
                    {
                            ForEach($VDITemplate in $VDITemplates)
                            {
                                    $TemplateProvider = Get-RASProvider -Id $RDSTemplate.ProviderId -EA 0 4>$Null
                                    
                                    If($? -and $Null -ne $TemplateProvider)
                                    {
                                            $TemplateProviderName = $TemplateProvider.Server
                                            $TemplateProviderType = GetVDIType $TemplateProvider.Type
                                    }
                                    Else
                                    {
                                            $TemplateProviderName = ""
                                            $TemplateProviderType = ""
                                    }
                                    
                                    $TemplateVM = Get-RASVM -Id $VDITemplate.VMId -ProviderId $VDITemplate.ProviderId -EA 0 4>$Null
                                    
                                    If($? -and $Null -ne $TemplateVM)
                                    {
                                #Nothing                                           <#
                                                    Values          Description
                                                    Unknown         The VM is in the 'Unknown' state
                                                    On                  The VM is powered on.
                                                    Off                 The VM is powered off
                                                    Paused          The VM is already, or in the process of being, suspended
                                                    CloningFailed   Failed to clone the VM.
                                                    CloningCanceled VM cloning was cancelled
                                            #>
                                            Switch($TemplateVM.State)
                                            {
                                                    "Unknown"                       {$TemplatePowerState = "Unknown"; Break}
                                                    "On"                            {$TemplatePowerState = "Powered on"; Break}
                                                    "Off"                           {$TemplatePowerState = "Powered off"; Break}
                                                    "Paused"                        {$TemplatePowerState = "Paused"; Break}
                                                    "CloningFailed"         {$TemplatePowerState = "Cloning failed"; Break}
                                                    "CloningCanceled"       {$TemplatePowerState = "Cloning canceled"; Break}
                                                    Default                         {$TemplatePowerState = "Unable to determine template VM power state: $($TemplateVM.State)"; Break}
                        }                                           }
                                    }
                                    Else
                                    {
                                            $TemplatePowerState = "Unknown"
                                    }
                                                          
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $ScriptInformation.Add(@{Data = "Enable Server in Site"; Value = $PA.Enabled.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Name"; Value = $VDITemplate.Name; }) > $Null
                                            #$ScriptInformation.Add(@{Data = "Status"; Value = "Can't find"; }) > $Null
                                $ScriptInformation.Add(@{Data = "Server"; Value = $PA.Server; }) > $Null                                           $ScriptInformation.Add(@{Data = "Power state"; Value = $TemplatePowerState; }) > $Null
                                $ScriptInformation.Add(@{Data = "IP"; Value = $PA.IP; }) > $Null                                           #$ScriptInformation.Add(@{Data = "Agent status"; Value = "Can't find"; }) > $Null
                                            #$ScriptInformation.Add(@{Data = "Distribution"; Value = "Can't find"; }) > $Null
                                $ScriptInformation.Add(@{Data = "Alternative IPs"; Value = $PA.AlternativeIPs; }) > $Null                                           $ScriptInformation.Add(@{Data = "Provider"; Value = $TemplateProviderName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Provider type"; Value = $TemplateProviderType; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PA.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Last modification by"; Value = $VDITemplate.AdminLastMod; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Modified on"; Value = $VDITemplate.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created by"; Value = $VDITemplate.AdminCreate; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created on"; Value = $VDITemplate.TimeCreate.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Standby"; Value = $PA.Standby.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "ID"; Value = $VDITemplate.Id.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                            Line 3 "Name: " $VDITemplate.Name
                                            #Line 3 "Status`t`t`t: " "Can't find"
                                            Line 3 "Power state`t`t: " $TemplatePowerState
                                            #Line 3 "Agent status`t`t: " "Can't find"
                                            #Line 3 "Distribution`t`t: " "Can't find"
                                Line 3 "Enable Server in Site`t: " $PA.Enabled.ToString()                                           Line 3 "Provider`t`t: " $TemplateProviderName
                                Line 3 "Server`t`t`t: " $PA.Server                                           Line 3 "Provider type`t`t: " $TemplateProviderType
                                Line 3 "IP`t`t`t: " $PA.IP                                           Line 3 "Last modification by`t: " $VDITemplate.AdminLastMod
                                            Line 3 "Modified on`t`t: " $VDITemplate.TimeLastMod.ToString()
                                Line 3 "Alternative IPs`t`t: " $PA.AlternativeIPs                                           Line 3 "Created by`t`t: " $VDITemplate.AdminCreate
                                Line 3 "Description`t`t: " $PA.Description                                           Line 3 "Created on`t`t: " $VDITemplate.TimeCreate.ToString()
                                Line 3 "Standby`t`t`t: " $PA.Standby.ToString()                                           Line 3 "ID`t`t`t: " $VDITemplate.Id.ToString()
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Enable Server in Site",($Script:htmlsb),$PA.Enabled.ToString(),$htmlwhite)                                           $columnHeaders = @("Name",($Script:htmlsb),$VDITemplate.Name,$htmlwhite)
                                            #$rowdata += @(,("Status",($Script:htmlsb),"Can't find",$htmlwhite))
                                $rowdata += @(,("Server",($Script:htmlsb),$PA.Server,$htmlwhite))                                           $rowdata += @(,("Power state",($Script:htmlsb),$TemplatePowerState,$htmlwhite))
                                $rowdata += @(,("IP",($Script:htmlsb),$PA.IP,$htmlwhite))                                           #$rowdata += @(,("Agent status",($Script:htmlsb),"Can't find",$htmlwhite))
                                            #$rowdata += @(,("Distribution",($Script:htmlsb),"Can't find",$htmlwhite))
                                $rowdata += @(,("Alternative IPs",($Script:htmlsb),$PA.AlternativeIPs,$htmlwhite))                                           $rowdata += @(,("Provider",($Script:htmlsb),$TemplateProviderName,$htmlwhite))
                                            $rowdata += @(,("Provider type",($Script:htmlsb),$TemplateProviderType,$htmlwhite))
                                $rowdata += @(,("Description",($Script:htmlsb),$PA.Description,$htmlwhite))                                           $rowdata += @(,("Last modification by",($Script:htmlsb), $VDITemplate.AdminLastMod,$htmlwhite))
                                            $rowdata += @(,("Modified on",($Script:htmlsb), $VDITemplate.TimeLastMod.ToString(),$htmlwhite))
                                            $rowdata += @(,("Created by",($Script:htmlsb), $VDITemplate.AdminCreate,$htmlwhite))
                                            $rowdata += @(,("Created on",($Script:htmlsb), $VDITemplate.TimeCreate.ToString(),$htmlwhite))
                                $rowdata += @(,("Standby",($Script:htmlsb),$PA.Standby.ToString(),$htmlwhite))                                           $rowdata += @(,("Id",($Script:htmlsb),$VDITemplate.Id.ToString(),$htmlwhite))
 
                                $msg = "Properties" <>                                         $msg = ""
                                $columnWidths = @("200","275")                                           $columnWidths = @("200","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
                }    
        }    
            
        #Enrollment Servers - not in PoSH    
            
        #HALB    
        If([version]$Script:RASVersion -ge [version]"18.3")    
        {    
                $HALBs = Get-RASHALB -Siteid $Site.Id -EA 0 4> $Null     
 
                If(!$?) <>  
                {    
                        Write-Warning "    
                        `n    
                        Unable to retrieve HALBs for Site $($Site.Name)`    
                        "    
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"    
                        }    
                        If($Text)    
                        {    
                                Line 0 "Unable to retrieve HALBs for Site $($Site.Name)"    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"    
                        }    
                }    
                ElseIf($? -and $Null -eq $HALBs)    
                {    
                        Write-Host "                                   #Properties
                        No HALBs retrieved for Site $($Site.Name).`    
                        " -ForegroundColor White    
                        If($MSWord -or $PDF)    
                        {                                   
                                WriteWordLine 0 0 "No HALBs retrieved for Site $($Site.Name)"    
                        }    
                        If($Text)    
                        {    
                                Line 0 "No HALBs retrieved for Site $($Site.Name)"    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 0 0 "No HALBs retrieved for Site $($Site.Name)"    
                        }    
                }    
                Else    
                {    
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 2 0 "HALB"                                           WriteWordLine 4 0 "General"
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 1 "HALB"                                           Line 3 "General"
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                WriteHTMLLine 2 0 "HALB"                                           #Nothing
                        }                                   }
     
                        Write-Verbose "$(Get-Date -Format G): `t`tOutput HALB"    
                        ForEach($HALB in $HALBs)    
                        {    
                                $HALBStatusResult = Get-RASHALBStatus -Name $HALB.Name -EA 0 4> $Null     
 
                                If($? -and $Null -ne $HALBStatusResult) <>                                 Switch ($VDITemplate.UnusedVMDurationMins)
 
                                        $HALBStatus = GetRASStatus $HALBStatusResult.AgentState <>                                         0               {$DeleteVMTime = "Never"; Break}
                                            5               {$DeleteVMTime = "5 minutes"; Break}
                                            30              {$DeleteVMTime = "30 minutes"; Break}
                                            60              {$DeleteVMTime = "1 hour"; Break}
                                            1440    {$DeleteVMTime = "1 day"; Break}
                                            10080   {$DeleteVMTime = "1 week"; Break}
                                            43200   {$DeleteVMTime = "30 days"; Break}
                                            Default {$DeleteVMTime = "Unable to determine Delete unused VMs after: $($VDITemplate.UnusedVMDurationMins)"; Break}
 
                                Else <>                                
                                    Switch($VDITemplate.CloneMethod)
 
                                        $HALBStatus = "Unable to determine HALB status" <>                                         "LinkedClone"   {$CloneMethod = "Create a linked clone"; Break}
                                            "FullClone"             {$CloneMethod = "Create a full clone"; Break}
                                            Default                 {$CloneMethod = "Unable to determine Clone method: $($VDITemplate.CloneMethod)"; Break}
 
                                 <>  
 
                                        WriteWordLine 3 0 "HALB $($HALB.Name)" +-  
 
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Template name"; Value = $VDITemplate.Name; }) > $Null
                                        $ScriptInformation.Add(@{Data = "IPv4"; Value = $HALB.VirtualIPV4; }) > $Null                                           $ScriptInformation.Add(@{Data = "Maximum guest VMs"; Value = $VDITemplate.MaxVMs.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "IPv6"; Value = $HALB.VirtualIPV6; }) > $Null                                           $ScriptInformation.Add(@{Data = "Keep available buffer"; Value = $VDITemplate.PreCreatedVMs.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $HALBStatus; }) > $Null                                           $ScriptInformation.Add(@{Data = "Guest VM name"; Value = $VDITemplate.VMNameFormat; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Guest VM state after the preparation"; Value = "Can't find"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Public Address"; Value = $HALB.PublicAddress; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $HALB.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $HALB.TimeLastMod.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Delete unused guest VMs after"; Value = $DeleteVMTime; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $HALB.AdminCreate; }) > $Null                                           $ScriptInformation.Add(@{Data = "Clone method"; Value = $CloneMethod; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $HALB.TimeCreate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $HALB.Id.ToString(); }) > $Null    
 
                                        Line 2 "HALB $($HALB.Name)" <>  
                                        Line 3 "Name`t`t`t: " $HALB.Name                                           Line 4 "Template name`t`t`t: " $VDITemplate.Name
                                        Line 3 "IPv4`t`t`t: " $HALB.VirtualIPV4    
                                        Line 3 "IPv6`t`t`t: " $HALB.VirtualIPV6    
                                        Line 3 "Status`t`t`t: " $HALBStatus    
                                        Line 3 "Description`t`t: " $HALB.Description    
                                        Line 3 "Public Address`t`t: " $HALB.PublicAddress    
                                        Line 3 "Last modification by`t: " $HALB.AdminLastMod    
                                        Line 3 "Modified on`t`t: " $HALB.TimeLastMod.ToString()                                           Line 4 "Maximum guest VMs`t`t: " $VDITemplate.MaxVMs.ToString()
                                        Line 3 "Created by`t`t: " $HALB.AdminCreate    
                                        Line 3 "Created on`t`t: " $HALB.TimeCreate.ToString()                                           Line 4 "Keep available buffer`t`t: " $VDITemplate.PreCreatedVMs.ToString()
                                        Line 3 "ID`t`t`t: " $HALB.Id.ToString()                                           Line 4 "Guest VM state after the preparation`t: " "Can't find"
                                            Line 4 "Guest VM name`t`t`t: " $VDITemplate.VMNameFormat
                                            Line 4 "Delete unused guest VMs after`t: " $DeleteVMTime
                                            Line 4 "Clone method`t`t`t: " $CloneMethod
 
                                        WriteHTMLLine 3 0 "HALB $($HALB.Name)" +-  
 
                                        $columnHeaders = @("Name",($Script:htmlsb),$HALB.Name,$htmlwhite) <>                                         $columnHeaders = @("Template name",($Script:htmlsb),$VDITemplate.Name,$htmlwhite)
                                        $rowdata += @(,("IPv4",($Script:htmlsb),$HALB.VirtualIPV4,$htmlwhite))                                           $rowdata += @(,("Maximum guest VMs",($Script:htmlsb),$VDITemplate.MaxVMs.ToString(),$htmlwhite))
                                        $rowdata += @(,("IPv6",($Script:htmlsb),$HALB.VirtualIPV6,$htmlwhite))                                           $rowdata += @(,("Keep available buffer",($Script:htmlsb),$VDITemplate.PreCreatedVMs.ToString(),$htmlwhite))
                                        $rowdata += @(,("Status",($Script:htmlsb),$HALBStatus,$htmlwhite))                                           $rowdata += @(,("Guest VM name",($Script:htmlsb),$VDITemplate.VMNameFormat,$htmlwhite))
                                        $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))                                           $rowdata += @(,("Guest VM state after the preparation",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $rowdata += @(,("Public Address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))    
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $HALB.AdminLastMod,$htmlwhite))    
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $HALB.TimeLastMod.ToString(),$htmlwhite))                                           $rowdata += @(,("Delete unused guest VMs after",($Script:htmlsb),$DeleteVMTime,$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $HALB.AdminCreate,$htmlwhite))                                           $rowdata += @(,("Clone method",($Script:htmlsb),$CloneMethod,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $HALB.TimeCreate.ToString(),$htmlwhite))    
                                        $rowdata += @(,("ID",($Script:htmlsb),$HALB.Id.ToString(),$htmlwhite))    
 
                                        $msg = "" <>                                         $msg = "Properties"
 
  <>                                 
                                    #Advanced
                                    
 
                                        WriteWordLine 4 0 "General" <>                                         WriteWordLine 4 0 "Advanced"
 
                                        Line 2 "General" <>                                         Line 3 "Advanced"
 
                                Switch($HALB.IPVersion) +-  
                                {    
                                        "Version4"              {$HALBIPVersion = "Version 4"; Break}    
                                        "Version6"              {$HALBIPVersion = "Version 6"; Break}    
                                        "BothVersions"  {$HALBIPVersion = "Both version 4 & 6"; Break}    
                                        Default                 {$HALBIPVersion = "Unable to determine IP version: $($HALB.IPVersion)"; Break}    
                                }    
                                    
 
                                        $ScriptInformation.Add(@{Data = "Enable HALB"; Value = $HALB.EnableHALBInstance.ToString(); }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Folder"; Value = $VDITemplate.FolderName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null                                           $ScriptInformation.Add(@{Data = "Resource pool"; Value = $VDITemplate.NativePoolName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Physical Host"; Value = $VDITemplate.PhysicalHostName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Public address"; Value = $HALB.PublicAddress; }) > $Null                                           $ScriptInformation.Add(@{Data = "Enable hardware acceleration graphics licensing support"; Value = $VDITemplate.HWGPU.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Virtual IP"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Use IP version"; Value = $HALBIPVersion; }) > $Null                                           #$ScriptInformation.Add(@{Data = "Use a separate network interface for LAN access"; Value = "Can't find"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     IPv4"; Value = $HALB.VirtualIPV4; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Subnet Mask"; Value = $HALB.SubNetMask; }) > $Null                                           #$ScriptInformation.Add(@{Data = "Specify management network details"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     IPv6"; Value = $HALB.VirtualIPV6; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Prefix"; Value = $HALB.PrefixIPV6; }) > $Null                                           #$ScriptInformation.Add(@{Data = "     Address"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null                                           #$ScriptInformation.Add(@{Data = "     Subnet mask"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     LB Gateway Payload"; Value = $HALB.EnableGWPayload.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     LB SSL Payload"; Value = $HALB.EnableSSLPayload.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Device Management"; Value = $HALB.EnableDeviceManagement.ToString(); }) > $Null    
 
                                        Line 3 "Enable HALB`t`t`t: " $HALB.EnableHALBInstance.ToString() <>  
                                        Line 3 "Name`t`t`t`t: " $HALB.Name                                           Line 4 "Folder`t`t`t`t: " $VDITemplate.FolderName
                                            Line 4 "Resource pool`t`t`t: " $VDITemplate.NativePoolName
                                            Line 4 "Physical Host`t`t`t: " $VDITemplate.PhysicalHostName
                                            Line 4 "Enable hardware acceleration "
                                        Line 3 "Description`t`t`t: " $HALB.Description                                           Line 4 "graphics licensing support`t: " $VDITemplate.HWGPU.ToString()
                                            #Line 4 "Use a separate network interface for LAN access: " "Can't find"
                                            #Line 4 "Specify management network details:"
                                        Line 3 "Public address`t`t`t: " $HALB.PublicAddress                                           #Line 5 "Address`t`t`t: " $DeleteVMTime
                                        Line 3 "Virtual IP"    
                                        Line 4 "Use IP version`t`t: " $HALBIPVersion    
                                        Line 4 "IPv4`t`t`t: " $HALB.VirtualIPV4    
                                        Line 4 "Subnet Mask`t`t: " $HALB.SubNetMask                                           #Line 6 "Subnet mask`t`t: " $CloneMethod
                                        Line 4 "IPv6`t`t`t: " $HALB.VirtualIPV6    
                                        Line 4 "Prefix`t`t`t: " $HALB.PrefixIPV6    
                                        Line 3 "Settings"    
                                        Line 4 "LB Gateway Payload`t: " $HALB.EnableGWPayload.ToString()    
                                        Line 4 "LB SSL Payload`t`t: " $HALB.EnableSSLPayload.ToString()    
                                        Line 4 "Device Management`t: " $HALB.EnableDeviceManagement.ToString()    
 
                                        $columnHeaders = @("Enable HALB",($Script:htmlsb),$HALB.EnableHALBInstance.ToString(),$htmlwhite) <>                                         $columnHeaders = @("Folder",($Script:htmlsb),$VDITemplate.FolderName,$htmlwhite)
                                        $rowdata += @(,("Name",($Script:htmlsb),$HALB.Name,$htmlwhite))                                           $rowdata += @(,("Resource pool",($Script:htmlsb),$VDITemplate.NativePoolName,$htmlwhite))
                                        $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))                                           $rowdata += @(,("Physical Host",($Script:htmlsb),$VDITemplate.PhysicalHostName,$htmlwhite))
                                        $rowdata += @(,("Public address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))                                           $rowdata += @(,("Enable hardware acceleration graphics licensing support",($Script:htmlsb),$VDITemplate.HWGPU.ToString(),$htmlwhite))
                                        $rowdata += @(,("Virtual IP",($Script:htmlsb), "",$htmlwhite))    
                                        $rowdata += @(,("     Use IP version",($Script:htmlsb), $HALBIPVersion,$htmlwhite))                                           #$rowdata += @(,("Use a separate network interface for LAN access",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $rowdata += @(,("     IPv4",($Script:htmlsb), $HALB.VirtualIPV4,$htmlwhite))    
                                        $rowdata += @(,("     Subnet Mask",($Script:htmlsb), $HALB.SubNetMask,$htmlwhite))                                           #$rowdata += @(,("Specify management network details",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,("     IPv6",($Script:htmlsb), $HALB.VirtualIPV6,$htmlwhite))    
                                        $rowdata += @(,("     Prefix",($Script:htmlsb), $HALB.PrefixIPV6,$htmlwhite))                                           #$rowdata += @(,("     Address",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,("Settings",($Script:htmlsb), "",$htmlwhite))                                           #$rowdata += @(,("     Subnet mask",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,("     LB Gateway Payload",($Script:htmlsb), $HALB.EnableGWPayload.ToString(),$htmlwhite))    
                                        $rowdata += @(,("     LB SSL Payload",($Script:htmlsb), $HALB.EnableSSLPayload.ToString(),$htmlwhite))    
                                        $rowdata += @(,("     Device Management",($Script:htmlsb), $HALB.EnableDeviceManagement.ToString(),$htmlwhite))    
 
                                        $msg = "General" <>                                         $msg = "Advanced"
                                        $columnWidths = @("200","400")                                           $columnWidths = @("200","275")
 
  <>                                 
                                    #Preparation
                                    
 
                                        WriteWordLine 4 0 "LB gateway payload" <>                                         WriteWordLine 4 0 "Preparation"
 
                                        Line 2 "LB gateway payload" <>                                         Line 3 "Preparation"
 
                                        WriteHTMLLine 4 0 "LB gateway payload" <>                                         #Nothing
 
                                $HALBGatewayPort = $HALB.GatewayConfig.Port.ToString() +-  
                                $HALBGateways    = $HALB.GatewayConfig.Gateways    
                                    
                                #First, get the port    
 
  <>                                         $ScriptInformation.Add(@{Data = "Image preparation tool"; Value = $VDITemplate.ImagePrepTool.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Computer name"; Value = $VDITemplate.ComputerName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Owner name"; Value = $VDITemplate.OwnerName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Organization"; Value = $VDITemplate.Organization; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Port"; Value = $HALBGatewayPort; }) > $Null                                           $ScriptInformation.Add(@{Data = "Active Directory domain"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Domain"; Value = $VDITemplate.Domain; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Administrator"; Value = $VDITemplate.Administrator; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Target OU"; Value = $VDITemplate.DomainOrgUnit; }) > $Null
 
  <>                                         Line 4 "Image preparation tool`t: " $VDITemplate.ImagePrepTool.ToString()
                                            Line 4 "Computer name`t`t: " $VDITemplate.ComputerName
                                            Line 4 "Owner name`t`t: " $VDITemplate.OwnerName
                                            Line 4 "Organization`t`t: " $VDITemplate.Organization
                                        Line 3 "Port: " $HALBGatewayPort                                           Line 4 "Active Directory domain"
                                            Line 5 "Domain`t`t: " $VDITemplate.Domain
                                            Line 5 "Administrator`t: " $VDITemplate.Administrator
                                            Line 5 "Target OU`t: " $VDITemplate.DomainOrgUnit
 
  <>                                         $columnHeaders = @("Image preparation tool",($Script:htmlsb),$VDITemplate.ImagePrepTool.ToString(),$htmlwhite)
                                        $columnHeaders = @("Port",($Script:htmlsb),$HALBGatewayPort,$htmlwhite)                                           $rowdata += @(,("Computer name",($Script:htmlsb),$VDITemplate.ComputerName,$htmlwhite))
                                            $rowdata += @(,("Owner name",($Script:htmlsb),$VDITemplate.OwnerName,$htmlwhite))
                                            $rowdata += @(,("Organization",($Script:htmlsb),$VDITemplate.Organization,$htmlwhite))
                                        #$rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Active Directory domain",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("     Domain",($Script:htmlsb),$VDITemplate.Domain,$htmlwhite))
                                            $rowdata += @(,("     Administrator",($Script:htmlsb),$VDITemplate.Administrator,$htmlwhite))
                                            $rowdata += @(,("     Target OU",($Script:htmlsb),$VDITemplate.DomainOrgUnit,$htmlwhite))
 
                                        $msg = "" <>                                         $msg = "Preparation"
                                        $columnWidths = @("200","400")                                           $columnWidths = @("200","275")
 
                                #second, process the gateways <>                                 #User Profile
                                #do output headers                          
 
                                        [System.Collections.Hashtable[]] $GatewaysWordTable = @(); <>                                         WriteWordLine 4 0 "User profile"
 
                                        Line 3 "Gateways                                                 Statu                                 " <>                                         Line 3 "User profile"
                                        Line 3 "================================================================================================="    
                                        #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890    
                                        #       1234567890123456789012345678901234567890123456789012345    
 
                                        $rowdata = @() <>                                         #Nothing
 
                                 <>  
                                #process the gateways data                                   If($VDITemplate.InheritDefaultUserProfileSettings)
                                ForEach($GWItem in $HALBGateways)    
 
                                        $ip = $GWItem.Keys <>                                         #do we inherit site defaults?
                                        $Results = [System.Net.Dns]::gethostentry($ip)                                           #yes we do, get the default settings for the Site
                                        $hostname = $Results.HostName                                           #use the Site default settings
                                            
                                            #Template technology settings do not include UPD, only FSLogix
                                        $TempGW = Get-RASGWStatus -Server $hostname -EA 0 4> $Null                                           $TemplateDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                        $HALBGWStatus = GetRASStatus $TempGW.AgentState    
 
                                        If($MSWord -or $PDF) <>                                         If($? -and $Null -ne $TemplateDefaults)
 
                                                $GatewaysWordTableRowHash = @{ <>  
                                                        Gateway       = "$hostname ($ip)";                                                   Switch ($TemplateDefaults.Technology)
                                                        GatewayStatus = $HALBGWStatus;                                                   {
                                                            "DoNotManage"                           {$TemplateTechnology = "Do not manage by RAS"; Break}
                                                            "FSLogixProfileContainer"       {$TemplateTechnology = "FSLogix"; Break}
                                                            Default                                         {$TemplateTechnology = "Unable to determine Technology State: $($TemplateDefaults.Technology)"; Break}
 
                                                $GatewaysWordTable += $GatewaysWordTableRowHash <>                                                
                                                    $FSLogixSettings           = $TemplateDefaults.FSLogix.ProfileContainer
                                                    $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id}
                                                    
                                                    Switch($FSLogixDeploymentSettings.InstallType)
                                                    {
                                                            "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}
                                                            "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}
                                                            "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}
                                                            "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}
                                                            Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}
                                        }                                                   }
                                                    
                                                    $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL
                                                    $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath
                                                    $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName
                                                    $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
     
                                                    Switch ($FSLogixSettings.LocationType)
                                                    {
                                                            "SMBLocation"   
                                                            {
                                                                    $FSLogixLocationType = "SMB Location"
                                                                    $FSLogixLocationOfProfileDisks = $FSLogixSettings.VHDLocations
                                                                    Break
                                                            }
                                                            "CloudCache"    
                                                            {
                                                                    $FSLogixLocationType = "Cloud Cache"
                                                                    $FSLogixLocationOfProfileDisks = $FSLogixSettings.CCDLocations
                                                                    Break
                                                            }
                                        If($Text)                                                           Default                
                                        {                                                           {
                                                Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)                                                                   $FSLogixLocationType = "Unable to determine FSLogix Location type: $($FSLogixSettings.LocationType)"
                                                                    $FSLogixLocationOfProfileDisks = @()
                                                                    Break
                                        }                                                           }
                                        If($HTML)                                                   }
                                                    
                                                    Switch ($FSLogixSettings.ProfileDiskFormat)
                                        {                                                   {
                                                $rowdata += @(,(                                                           "VHD"   {$FSLogixProfileDiskFormat = "VHD"; Break}
                                                "$hostname ($ip)",$htmlwhite,                                                           "VHDX"  {$FSLogixProfileDiskFormat = "VHDX"; Break}
                                                $HALBGWStatus,$htmlwhite))                                                           Default {$FSLogixProfileDiskFormat = "Unable to determine FSLogix Profile disk format: $($FSLogixSettings.ProfileDiskFormat)"; Break}
                                        }                                                   }
                                                    
                                                    Switch ($FSLogixSettings.AllocationType)
                                                    {
                                                            "Dynamic"       {$FSLogixAllocationType = "Dynamic"; Break}
                                                            "Full"          {$FSLogixAllocationType = "Full"; Break}
                                                            Default         {$FSLogixAllocationType = "Unable to determine FSLogix Allocation type: $($FSLogixSettings.AllocationType)"; Break}
                                }                                                   }
                                                                                  
                                #output the Word/PDF and HTML tables                                                   $FSLogixDefaultSize = $FSLogixSettings.DefaultSize.ToString()
                                If($MSWord -or $PDF)                                                          
                                                    #FSLogix Additional settings
                                                    #Users and Groups tab
                                                    If($FSLogixSettings.UserInclusionList.Count -eq 0)
                                {                                                   {
                                        If($GatewaysWordTable.Count -gt 0)                                                           $FSLogixSettingsUserInclusionList = @("Everyone")
                                                    }
                                                    Else
                                        {                                                   {
                                                $Table = AddWordTable -Hashtable $GatewaysWordTable `                                                           $FSLogixSettingsUserInclusionList = $FSLogixSettings.UserInclusionList
                                                -Columns  Gateway,GatewayStatus `                                                   }
                                                -Headers  "Gateways","Status"`                                                   $FSLogixSettingsUserExclusionList       = $FSLogixSettings.UserExclusionList
                                                            
                                                -Format $wdTableGrid `                                                   #Folders tab
                                                -AutoFit $wdAutoFitFixed;                                                   $FSLogixSettingsCustomizeProfileFolders = $FSLogixSettings.CustomizeProfileFolders
                                                    $FSLogixSettingsExcludeCommonFolders    = $FSLogixSettings | Select-Object -ExpandProperty ExcludeCommonFolders
                                                    $ExcludedCommonFolders                  = @()
                                                    $FSLogixSettingsFolderInclusionList     = $FSLogixSettings.FolderInclusionList
                                                    $FSLogixSettingsFolderExclusionList     = $FSLogixSettings.FolderExclusionList
 
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15; <>                                                 If($FSLogixSettingsCustomizeProfileFolders)
                                                    {
                                                $Table.Columns.Item(1).Width = 200;                                                           #####################################################################################
                                                $Table.Columns.Item(2).Width = 250;                                                           #MANY thanks to Guy Leech for helping me figure out how to process and use this Enum#
                                                            #####################################################################################
 
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                                         #this is cumulative
                                                            #Contacts, Desktop, Documents, Links, MusicPodcasts, PicturesVideos, FoldersLowIntegProcesses
                                                            If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Contacts)
                                                            {
                                                                    $ExcludedCommonFolders += "Contacts"
                                                            }
                                                            If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Desktop)
                                                            {
                                                FindWordDocumentEnd                                                                   $ExcludedCommonFolders += "Desktop"
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }                                                           }
                                                            If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Documents)
                                                            {
                                                                    $ExcludedCommonFolders += "Documents"
                                }                                                           }
                                If($Text)                                                           If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Links)
                                {                                                           {
                                                                    $ExcludedCommonFolders += "Links"
                                        Line 0 ""                                                           }
                                                            If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::MusicPodcasts)
                                                            {
                                                                    $ExcludedCommonFolders += 'Music & Podcasts'
                                }                                                           }
                                If($HTML)                                                           If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::PicturesVideos)
                                {                                                           {
                                        $columnHeaders = @(                                                                   $ExcludedCommonFolders += 'Pictures & Videos'
                                        "Gateways",($Script:htmlsb),                                                           }
                                        "Status",($Script:htmlsb))                                                           If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::FoldersLowIntegProcesses)
                                                            {
                                                                    $ExcludedCommonFolders += "Folders used by Low Integrity processes"
                                        $msg = ""                                                           }
                                        $columnWidths = @("200","400")    
                                        FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"    
                                        WriteHTMLLine 0 0 ""    
                                }                                                   }
                                                            
                                                    #Advanced tab
                                                    $FSLogixAS = $FSLogixSettings.AdvancedSettings
                                                                                  
                                If($MSWord -or $PDF)                                                   Switch($FSLogixAS.AccessNetworkAsComputerObject)
                                {                                                   {
                                        WriteWordLine 4 0 "LB SSL payload"                                                           "Enable"        {$FSLogixAS_AccessNetworkAsComputerObject = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_AccessNetworkAsComputerObject = "Disable"; Break}
                                                            Default         {$FSLogixAS_AccessNetworkAsComputerObject = "Unknown: $($FSLogixAS.AccessNetworkAsComputerObject)"; Break}
                                }                                                   }
                                If($Text)                                                  
                                                    $FSLogixAS_AttachVHDSDDL = $FSLogixAS.AttachVHDSDDL
                                                    
                                                    Switch($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)
                                {                                                   {
                                        Line 2 "LB SSL payload"                                                           "Enable"        {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"; Break}
                                                            Default         {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Unknown: $($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)"; Break}
                                }                                                   }
                                If($HTML)    
                                                    $FSLogixAS_DiffDiskParentFolderPath = $FSLogixAS.DiffDiskParentFolderPath  
     
                                                    Switch($FSLogixAS.FlipFlopProfileDirectoryName)
                                {                                                   {
                                        #Nothing                                                           "Enable"        {$FSLogixAS_FlipFlopProfileDirectoryName = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_FlipFlopProfileDirectoryName = "Disable"; Break}
                                                            Default         {$FSLogixAS_FlipFlopProfileDirectoryName = "Unknown: $($FSLogixAS.FlipFlopProfileDirectoryName)"; Break}
                                }                                                   }
                                                                                  
                                                    Switch($FSLogixAS.KeepLocalDir)
                                                    {
                                                            "Enable"        {$FSLogixAS_KeepLocalDir = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_KeepLocalDir = "Disable"; Break}
                                                            Default         {$FSLogixAS_KeepLocalDir = "Unknown: $($FSLogixAS.KeepLocalDir)"; Break}
                                                    }
     
                                $HALBSSLGatewayPort = $HALB.SSLConfig.GatewayConfig.Port.ToString()                                                   $FSLogixAS_LockedRetryCount    = $FSLogixAS.LockedRetryCount                       
                                $HALBSSLGateways    = $HALB.SSLConfig.GatewayConfig.Gateways                                                   $FSLogixAS_LockedRetryInterval = $FSLogixAS.LockedRetryInterval     
                                                                                  
                                                    Switch($FSLogixAS.NoProfileContainingFolder)
                                                    {
                                                            "Enable"        {$FSLogixAS_NoProfileContainingFolder = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_NoProfileContainingFolder = "Disable"; Break}
                                                            Default         {$FSLogixAS_NoProfileContainingFolder = "Unknown: $($FSLogixAS.NoProfileContainingFolder)"; Break}
                                                    }
     
                                Switch($HALB.SSLConfig.SSLMode)                                                   Switch($FSLogixAS.OutlookCachedMode)
                                {                                                   {
                                        "SSLOffloading"         {$HALBSSLMode = "SSL Offloading"; Break}                                                           "Enable"        {$FSLogixAS_OutlookCachedMode = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_OutlookCachedMode = "Disable"; Break}
                                                            Default         {$FSLogixAS_OutlookCachedMode = "Unknown: $($FSLogixAS.OutlookCachedMode)"; Break}
                                                    }
     
                                                    Switch($FSLogixAS.PreventLoginWithFailure)
                                                    {
                                                            "Enable"        {$FSLogixAS_PreventLoginWithFailure = "Enable"; Break}
                                        "SSLPassthrough"        {$HALBSSLMode = "Passthrough"; Break}                                                           "Disable"       {$FSLogixAS_PreventLoginWithFailure = "Disable"; Break}
                                                            Default         {$FSLogixAS_PreventLoginWithFailure = "Unknown: $($FSLogixAS.PreventLoginWithFailure)"; Break}
                                                    }
     
                                                    Switch($FSLogixAS.PreventLoginWithTempProfile)
                                                    {
                                                            "Enable"        {$FSLogixAS_PreventLoginWithTempProfile = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_PreventLoginWithTempProfile = "Disable"; Break}
                                                            Default         {$FSLogixAS_PreventLoginWithTempProfile = "Unknown: $($FSLogixAS.PreventLoginWithTempProfile)"; Break}
                                                    }
     
                                                    $FSLogixAS_ProfileDirSDDL = $FSLogixAS.ProfileDirSDDL
     
                                                    Switch($FSLogixAS.ProfileType)
                                                    {
                                                            "NormalProfile" {$FSLogixAS_ProfileType = "Normal profile"; Break}
                                                            "OnlyRWProfile" {$FSLogixAS_ProfileType = "Only RW profile"; Break}
                                                            "OnlyROProfile" {$FSLogixAS_ProfileType = "Only RO profile"; Break}
                                                            "RWROProfile"   {$FSLogixAS_ProfileType = "RW/RO profile"; Break}
                                                            Default                 {$FSLogixAS_ProfileType = "Unknown: $($FSLogixAS.ProfileType)"; Break}
                                                    }
     
                                                    $FSLogixAS_ReAttachIntervalSeconds = $FSLogixAS.ReAttachIntervalSeconds                
                                                    $FSLogixAS_ReAttachRetryCount      = $FSLogixAS.ReAttachRetryCount                     
     
                                                    Switch($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)
                                                    {
                                                            "Enable"        {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Disable"; Break}
                                                            Default         {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Unknown: $($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)"; Break}
                                                    }
     
                                                    Switch($FSLogixAS.RoamSearch)
                                                    {
                                                            "Enable"        {$FSLogixAS_RoamSearch = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_RoamSearch = "Disable"; Break}
                                                            Default         {$FSLogixAS_RoamSearch = "Unknown: $($FSLogixAS.RoamSearch)"; Break}
                                                    }
     
                                                    Switch($FSLogixAS.SetTempToLocalPath)
                                                    {
                                                            "TakeNoAction"                                  {$FSLogixAS_SetTempToLocalPath = "Take no action"; Break}
                                                            "RedirectTempAndTmp"                    {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP and TMP"; Break}
                                                            "RedirectINetCache"                             {$FSLogixAS_SetTempToLocalPath = "Redirect INetCache"; Break}
                                                            "RedirectTempTmpAndINetCache"   {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP, TMP, and INetCache"; Break}
                                                            Default                                                 {$FSLogixAS_SetTempToLocalPath = "Unknown: $($FSLogixAS.SetTempToLocalPath)"; Break}
                                                    }
     
                                                    $FSLogixAS_SIDDirNameMatch   = $FSLogixAS.SIDDirNameMatch                        
                                                    $FSLogixAS_SIDDirNamePattern = $FSLogixAS.SIDDirNamePattern                      
                                                    $FSLogixAS_SIDDirSDDL        = $FSLogixAS.SIDDirSDDL
                                                    $FSLogixAS_VHDNameMatch      = $FSLogixAS.VHDNameMatch                           
                                                    $FSLogixAS_VHDNamePattern    = $FSLogixAS.VHDNamePattern                         
     
                                                    Switch($FSLogixAS.VHDXSectorSize)
                                                    {
                                                            0               {$FSLogixAS_VHDXSectorSize = "System default"; Break}
                                                            512             {$FSLogixAS_VHDXSectorSize = "512"; Break}
                                                            4096    {$FSLogixAS_VHDXSectorSize = "4096"; Break}
                                        Default                         {$HALBSSLMode = "Unable to etermine SSL Mode: $($HALB.SSLConfig.SSLMode)"; Break}                                                           Default {$FSLogixAS_VHDXSectorSize = "Unknown: $($FSLogixAS.VHDXSectorSize)"; Break}
                                                    }
     
                                                    $FSLogixAS_VolumeWaitTimeMS = $FSLogixAS.VolumeWaitTimeMS                                                               
                                            }
                                            Else
                                            {
                                                    #unable to retrieve default, use built-in default values
                                                    $TemplateTechnology                             = "Do not manage by RAS"
                                                    $FSLogixDeploymentSettingsDeploymentMethod      = "None"
                                                    $FSLogixDeploymentSettingsInstallOnlineURL      = "None"
                                                    $FSLogixDeploymentSettingsNetworkDrivePath      = "None"
                                                    $FSLogixDeploymentSettingsInstallerFileName     = "None"
                                                    $FSLogixDeploymentSettingsReplicate             = $False
                                                    $FSLogixLocationType                            = "None"
                                                    $FSLogixLocationOfProfileDisks                  = @()
                                                    $FSLogixProfileDiskFormat                       = "None"
                                                    $FSLogixAllocationType                          = "None"
                                                    $FSLogixDefaultSize                             = "0"
                                                    $FSLogixSettingsUserInclusionList               = @("Everyone")
                                                    $FSLogixSettingsUserExclusionList               = @()
                                                    $FSLogixSettingsCustomizeProfileFolders         = $False
                                                    $FSLogixSettingsExcludeCommonFolders            = "None"
                                                    $ExcludedCommonFolders                          = @()
                                                    $FSLogixSettingsFolderInclusionList             = @()
                                                    $FSLogixSettingsFolderExclusionList             = @()
                                                    $FSLogixAS_AccessNetworkAsComputerObject        = "Disable"
                                                    $FSLogixAS_AttachVHDSDDL                        = "None"
                                                    $FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"
                                                    $FSLogixAS_DiffDiskParentFolderPath             = "%TEMP"
                                                    $FSLogixAS_FlipFlopProfileDirectoryName         = "Disable"
                                                    $FSLogixAS_KeepLocalDir                         = "Disable"
                                                    $FSLogixAS_LockedRetryCount                     = 12
                                                    $FSLogixAS_LockedRetryInterval                  = 5
                                                    $FSLogixAS_NoProfileContainingFolder            = "Disable"
                                                    $FSLogixAS_OutlookCachedMode                    = "Disable"
                                                    $FSLogixAS_PreventLoginWithFailure              = "Disable"
                                                    $FSLogixAS_PreventLoginWithTempProfile          = "Disable"
                                                    $FSLogixAS_ProfileDirSDDL                       = "None"
                                                    $FSLogixAS_ProfileType                          = "Normal profile"
                                                    $FSLogixAS_ReAttachIntervalSeconds              = 10
                                                    $FSLogixAS_ReAttachRetryCount                   = 60
                                                    $FSLogixAS_RemoveOrphanedOSTFilesOnLogoff       = "Enable"
                                                    $FSLogixAS_RoamSearch                           = "Disable"
                                                    $FSLogixAS_SetTempToLocalPath                   = "Redirect TEMP, TMP, and INetCache"
                                                    $FSLogixAS_SIDDirNameMatch                      = "%sid%_%username%"
                                                    $FSLogixAS_SIDDirNamePattern                    = "%sid%_%username%"
                                                    $FSLogixAS_SIDDirSDDL                           = "None"
                                                    $FSLogixAS_VHDNameMatch                         = "Profile*"
                                                    $FSLogixAS_VHDNamePattern                       = "Profile_%username%"
                                                    $FSLogixAS_VHDXSectorSize                       = "System default"
                                                    $FSLogixAS_VolumeWaitTimeMS                     = 20000
                                            }
 
  <>                                 Else
                                    {
                                            #we don't inherit
                                            #get the settings for the template
     
                                            Switch ($VDITemplate.Technology)
                                            {
                                                    "DoNotManage"                           {$TemplateTechnology = "Do not manage by RAS"; Break}
                                                    "FSLogixProfileContainer"       {$TemplateTechnology = "FSLogix"; Break}
                                                    Default                                         {$TemplateTechnology = "Unable to determine Technology State: $($VDITemplate.Technology)"; Break}
                                            }
                                                            
                                            $FSLogixSettings           = $VDITemplate.FSLogix.ProfileContainer
                                            $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id}
                                                                          
                                If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")                                           Switch($FSLogixDeploymentSettings.InstallType)
                                {                                           {
                                                    "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}
                                                    "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}
                                                    "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}
                                                    "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}
                                                    Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}
                                            }
                                            
                                            $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL
                                            $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath
                                            $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName
                                            $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
                                            
                                        Switch($HALB.SSLConfig.MinSSLVersion)                                           Switch ($FSLogixSettings.LocationType)
 
                                                "SSLv2"         {$HALBSSLAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break} <>                                                 "SMBLocation"  
                                                "SSLv3"         {$HALBSSLAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}                                                   {
                                                "TLSv1"         {$HALBSSLAcceptedSSLVersions = "TLS v1.0 - TLS v1.2"; Break}                                                           $FSLogixLocationType = "SMB Location"
                                                "TLSv1_1"       {$HALBSSLAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}                                                           $FSLogixLocationOfProfileDisks = $FSLogixSettings.VHDLocations
                                                "TLSv1_2"       {$HALBSSLAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}                                                           Break
                                                    }
                                                    "CloudCache"    
                                                    {
                                                            $FSLogixLocationType = "Cloud Cache"
                                                            $FSLogixLocationOfProfileDisks = $FSLogixSettings.CCDLocations
                                                            Break
                                                    }
                                                    Default                 
                                                    {
                                                            $FSLogixLocationType = "Unable to determine FSLogix Location type: $($FSLogixSettings.LocationType)"
                                                            $FSLogixLocationOfProfileDisks = @()
                                                            Break
                                                    }
                                            }
                                            
                                            Switch ($FSLogixSettings.ProfileDiskFormat)
                                            {
                                                    "VHD"   {$FSLogixProfileDiskFormat = "VHD"; Break}
                                                    "VHDX"  {$FSLogixProfileDiskFormat = "VHDX"; Break}
                                                    Default {$FSLogixProfileDiskFormat = "Unable to determine FSLogix Profile disk format: $($FSLogixSettings.ProfileDiskFormat)"; Break}
                                            }
                                            
                                            Switch ($FSLogixSettings.AllocationType)
                                            {
                                                    "Dynamic"       {$FSLogixAllocationType = "Dynamic"; Break}
                                                    "Full"          {$FSLogixAllocationType = "Full"; Break}
                                                Default         {$HALBSSLAcceptedSSLVersions = "Unable to determine Minimum SSL version: $($HALB.SSLConfig.MinSSLVersion)"; Break}                                                   Default         {$FSLogixAllocationType = "Unable to determine FSLogix Allocation type: $($FSLogixSettings.AllocationType)"; Break}
 
  <>                                         $FSLogixDefaultSize = $FSLogixSettings.DefaultSize.ToString()
                                                            
                                            #FSLogix Additional settings
                                            #Users and Groups tab
                                        If($HALB.SSLConfig.SSLCipherStrength -eq "Custom")                                           If($FSLogixSettings.UserInclusionList.Count -eq 0)
 
                                                $HALBSSLCipherStrength = "Custom" <>                                                 $FSLogixSettingsUserInclusionList = @("Everyone")
                                                $HALBSSLCipher         = $HALB.SSLConfig.SSLCustomCipher    
 
                                                $HALBSSLCipherStrength = $HALB.SSLConfig.SSLCipherStrength <>                                                 $FSLogixSettingsUserInclusionList = $FSLogixSettings.UserInclusionList
                                            }
                                            $FSLogixSettingsUserExclusionList       = $FSLogixSettings.UserExclusionList
                                                            
                                            #Folders tab
                                            $FSLogixSettingsCustomizeProfileFolders = $FSLogixSettings.CustomizeProfileFolders
                                            $FSLogixSettingsExcludeCommonFolders    = $FSLogixSettings | Select-Object -ExpandProperty ExcludeCommonFolders
                                            $ExcludedCommonFolders                  = @()
                                            $FSLogixSettingsFolderInclusionList     = $FSLogixSettings.FolderInclusionList
                                            $FSLogixSettingsFolderExclusionList     = $FSLogixSettings.FolderExclusionList
     
                                            If($FSLogixSettingsCustomizeProfileFolders)
                                            {
                                                    #####################################################################################
                                                    #MANY thanks to Guy Leech for helping me figure out how to process and use this Enum#
                                                    #####################################################################################
     
                                                    #this is cumulative
                                                    #Contacts, Desktop, Documents, Links, MusicPodcasts, PicturesVideos, FoldersLowIntegProcesses
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Contacts)
                                                    {
                                                            $ExcludedCommonFolders += "Contacts"
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Desktop)
                                                    {
                                                            $ExcludedCommonFolders += "Desktop"
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Documents)
                                                    {
                                                            $ExcludedCommonFolders += "Documents"
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Links)
                                                    {
                                                            $ExcludedCommonFolders += "Links"
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::MusicPodcasts)
                                                    {
                                                            $ExcludedCommonFolders += 'Music & Podcasts'
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::PicturesVideos)
                                                    {
                                                            $ExcludedCommonFolders += 'Pictures & Videos'
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::FoldersLowIntegProcesses)
                                                    {
                                                            $ExcludedCommonFolders += "Folders used by Low Integrity processes"
                                                    }
                                            }
                                            
                                            #Advanced tab
                                            $FSLogixAS = $FSLogixSettings.AdvancedSettings
                                            
                                            Switch($FSLogixAS.AccessNetworkAsComputerObject)
                                            {
                                                    "Enable"        {$FSLogixAS_AccessNetworkAsComputerObject = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_AccessNetworkAsComputerObject = "Disable"; Break}
                                                    Default         {$FSLogixAS_AccessNetworkAsComputerObject = "Unknown: $($FSLogixAS.AccessNetworkAsComputerObject)"; Break}
                                            }
                                            
                                            $FSLogixAS_AttachVHDSDDL = $FSLogixAS.AttachVHDSDDL
                                            
                                            Switch($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)
                                            {
                                                    "Enable"        {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"; Break}
                                                    Default         {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Unknown: $($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)"; Break}
                                            }
     
                                            $FSLogixAS_DiffDiskParentFolderPath = $FSLogixAS.DiffDiskParentFolderPath  
     
                                            Switch($FSLogixAS.FlipFlopProfileDirectoryName)
                                            {
                                                    "Enable"        {$FSLogixAS_FlipFlopProfileDirectoryName = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_FlipFlopProfileDirectoryName = "Disable"; Break}
                                                    Default         {$FSLogixAS_FlipFlopProfileDirectoryName = "Unknown: $($FSLogixAS.FlipFlopProfileDirectoryName)"; Break}
                                            }
                                            
                                            Switch($FSLogixAS.KeepLocalDir)
                                            {
                                                    "Enable"        {$FSLogixAS_KeepLocalDir = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_KeepLocalDir = "Disable"; Break}
                                                    Default         {$FSLogixAS_KeepLocalDir = "Unknown: $($FSLogixAS.KeepLocalDir)"; Break}
                                            }
     
                                            $FSLogixAS_LockedRetryCount    = $FSLogixAS.LockedRetryCount                       
                                            $FSLogixAS_LockedRetryInterval = $FSLogixAS.LockedRetryInterval     
                                            
                                            Switch($FSLogixAS.NoProfileContainingFolder)
                                            {
                                                    "Enable"        {$FSLogixAS_NoProfileContainingFolder = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_NoProfileContainingFolder = "Disable"; Break}
                                                    Default         {$FSLogixAS_NoProfileContainingFolder = "Unknown: $($FSLogixAS.NoProfileContainingFolder)"; Break}
                                            }
     
                                            Switch($FSLogixAS.OutlookCachedMode)
                                            {
                                                    "Enable"        {$FSLogixAS_OutlookCachedMode = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_OutlookCachedMode = "Disable"; Break}
                                                    Default         {$FSLogixAS_OutlookCachedMode = "Unknown: $($FSLogixAS.OutlookCachedMode)"; Break}
                                            }
     
                                            Switch($FSLogixAS.PreventLoginWithFailure)
                                            {
                                                    "Enable"        {$FSLogixAS_PreventLoginWithFailure = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_PreventLoginWithFailure = "Disable"; Break}
                                                    Default         {$FSLogixAS_PreventLoginWithFailure = "Unknown: $($FSLogixAS.PreventLoginWithFailure)"; Break}
                                            }
     
                                                Switch($HALB.SSLConfig.SSLCipherStrength)                                           Switch($FSLogixAS.PreventLoginWithTempProfile)
                                                {                                           {
                                                        "Low"           {$HALBSSLCipher = "All:!aNULL:!eNULL"; Break}                                                   "Enable"        {$FSLogixAS_PreventLoginWithTempProfile = "Enable"; Break}
                                                        "Medium"        {$HALBSSLCipher = "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"; Break}                                                   "Disable"       {$FSLogixAS_PreventLoginWithTempProfile = "Disable"; Break}
                                                        "High"          {$HALBSSLCipher = "EECDH:!SSLv2:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"; Break}    
                                                        Default         {$HALBSSLCipher = "Unable to determine SSL cipher strength: $($HALB.SSLConfig.SSLCipherStrength)"; Break}                                                   Default         {$FSLogixAS_PreventLoginWithTempProfile = "Unknown: $($FSLogixAS.PreventLoginWithTempProfile)"; Break}
                                                }                                           }
     
                                            $FSLogixAS_ProfileDirSDDL = $FSLogixAS.ProfileDirSDDL
     
                                            Switch($FSLogixAS.ProfileType)
                                            {
                                                    "NormalProfile" {$FSLogixAS_ProfileType = "Normal profile"; Break}
                                                    "OnlyRWProfile" {$FSLogixAS_ProfileType = "Only RW profile"; Break}
                                                    "OnlyROProfile" {$FSLogixAS_ProfileType = "Only RO profile"; Break}
                                                    "RWROProfile"   {$FSLogixAS_ProfileType = "RW/RO profile"; Break}
                                                    Default         {$FSLogixAS_ProfileType = "Unknown: $($FSLogixAS.ProfileType)"; Break}
 
                                        $HALBSSLUseServerPreference = $HALB.SSLConfig.SSLCipherPreference.ToString() <>  
                                        If($HALB.SSLConfig.CertID -eq 0)                                           $FSLogixAS_ReAttachIntervalSeconds = $FSLogixAS.ReAttachIntervalSeconds               
                                            $FSLogixAS_ReAttachRetryCount      = $FSLogixAS.ReAttachRetryCount                     
     
                                            Switch($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)
 
  <>                                                 "Enable"        {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Disable"; Break}
                                                    Default         {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Unknown: $($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)"; Break}
                                            }
     
                                            Switch($FSLogixAS.RoamSearch)
                                            {
                                                    "Enable"        {$FSLogixAS_RoamSearch = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_RoamSearch = "Disable"; Break}
                                                    Default         {$FSLogixAS_RoamSearch = "Unknown: $($FSLogixAS.RoamSearch)"; Break}
                                            }
     
                                            Switch($FSLogixAS.SetTempToLocalPath)
                                            {
                                                    "TakeNoAction"                                  {$FSLogixAS_SetTempToLocalPath = "Take no action"; Break}
                                                    "RedirectTempAndTmp"                    {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP and TMP"; Break}
                                                    "RedirectINetCache"                             {$FSLogixAS_SetTempToLocalPath = "Redirect INetCache"; Break}
                                                    "RedirectTempTmpAndINetCache"   {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP, TMP, and INetCache"; Break}
                                                    Default                                                 {$FSLogixAS_SetTempToLocalPath = "Unknown: $($FSLogixAS.SetTempToLocalPath)"; Break}
                                            }
     
                                            $FSLogixAS_SIDDirNameMatch   = $FSLogixAS.SIDDirNameMatch                        
                                            $FSLogixAS_SIDDirNamePattern = $FSLogixAS.SIDDirNamePattern                      
                                            $FSLogixAS_SIDDirSDDL        = $FSLogixAS.SIDDirSDDL
                                            $FSLogixAS_VHDNameMatch      = $FSLogixAS.VHDNameMatch                           
                                            $FSLogixAS_VHDNamePattern    = $FSLogixAS.VHDNamePattern                         
     
                                            Switch($FSLogixAS.VHDXSectorSize)
                                            {
                                                $HALBSSLCertificates = "All matching usage"                                                   0               {$FSLogixAS_VHDXSectorSize = "System default"; Break}
                                                    512             {$FSLogixAS_VHDXSectorSize = "512"; Break}
                                                    4096    {$FSLogixAS_VHDXSectorSize = "4096"; Break}
                                                    Default {$FSLogixAS_VHDXSectorSize = "Unknown: $($FSLogixAS.VHDXSectorSize)"; Break}
 
  <>  
                                            $FSLogixAS_VolumeWaitTimeMS = $FSLogixAS.VolumeWaitTimeMS                                                               
                                    }
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultUserProfileSettings.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Technology"; Value = $TemplateTechnology; }) > $Null
     
                                            If($TemplateTechnology -eq "Do not manage by RAS")
                                            {
                                                    #do nothing
                                            }
                                            ElseIf($TemplateTechnology -eq "FSLogix")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Deployment method"; Value = $FSLogixDeploymentSettingsDeploymentMethod; }) > $Null
                                                    If($FSLogixDeploymentSettings.InstallType -eq "Online")
                                                    {
                                                            $ScriptInformation.Add(@{Data = "URL"; Value = $FSLogixDeploymentSettingsInstallOnlineURL; }) > $Null
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                                                    {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsNetworkDrivePath; }) > $Null
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                                                    {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsInstallerFileName; }) > $Null
                                                    }
                                                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Location type"; Value = $FSLogixLocationType; }) > $Null
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $FSLogixLocationOfProfileDisks)
                                                    {
                                                            $cnt++
                                                            
                                                            If($cnt -eq 0)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "     Location of profile disks"; Value = $item; }) > $Null
                                                            }
                                        Else                                                           Else
                                        {                                                           {
                                                $Results = Get-RASCertificate -Id $HALB.SSLConfig.CertID -EA 0 4> $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                            }
                                                    }
                                                    $ScriptInformation.Add(@{Data = "     Profile disk format"; Value = $FSLogixProfileDiskFormat; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Allocation type"; Value = $FSLogixAllocationType; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Default size"; Value = "$FSLogixDefaultSize GB"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Additional settings"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Users and Groups"; Value = ""; }) > $Null
 
                                                If($? -and $Null -ne $Results) <>                                                 If($FSLogixSettingsUserInclusionList.Count -eq 0)
 
                                                        $HALBSSLCertificates = $Results.Name <>                                                         $ScriptInformation.Add(@{Data = "          User Inclusion List"; Value = "None"; }) > $Null
 
  <>                                                         $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                        $HALBSSLCertificates = "Unable to find certificate with an ID of $($HALB.SSLConfig.CertID)"                                                                           $ScriptInformation.Add(@{Data = "          User Inclusion List"; Value = "User: $($item.Account)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "User: $($item.Account)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                                    }
                                                            }
 
  <>  
                                                    If($FSLogixSettingsUserExclusionList.Count -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = ""; }) > $Null
                                        }                                                   }
                                                    Else
                                                    {
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            #$ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = "User: $($item.Account)  Type: $($item.Type)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = "User: $($item.Account)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                }                                                                   }
                                Else                                                                   Else
                                {                                                                   {
                                        $HALBSSLAcceptedSSLVersions = ""                                                                           $ScriptInformation.Add(@{Data = ""; Value = "User: $($item.Account)"; }) > $Null
                                        $HALBSSLCipherStrength      = ""                                                                           $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null
                                        $HALBSSLCipher              = ""                                                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                        $HALBSSLUseServerPreference = ""                                                                   }
                                        $HALBSSLCertificates        = ""                                                           }
                                }                                                   }
                                                    $ScriptInformation.Add(@{Data = "     Folders"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Customize profile folders"; Value = $FSLogixSettingsCustomizeProfileFolders.ToString(); }) > $Null
                                                    If($FSLogixSettingsCustomizeProfileFolders)
                                                    {
                                                            If($ExcludedCommonFolders.Count -gt 0)
                                                            {
                                                                    $cnt = -1
                                                                    ForEach($item in $ExcludedCommonFolders)
                                                                    {
                                                                            $cnt++
                                                                                                          
                                #First, get the port                                                                           If($cnt -eq 0)
                                If($MSWord -or $PDF)                                                                           {
                                                                                    $ScriptInformation.Add(@{Data = "               Exclude Common Folders"; Value = $item; }) > $Null
                                                                            }
                                                                            Else
                                {                                                                           {
                                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                            }
                                                                    }
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "               Exclude Common Folders"; Value = "None"; }) > $Null
                                                            }
                                                    }
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                                   If($FSLogixSettingsFolderInclusionList.Count -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "          Folder Inclusion List"; Value = "None"; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = "          Folder Inclusion List"; Value = ""; }) > $Null
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                        $ScriptInformation.Add(@{Data = "Port"; Value = $HALBSSLGatewayPort; }) > $Null                                                                           $ScriptInformation.Add(@{Data = "               Folder"; Value = "$item"; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                        $ScriptInformation.Add(@{Data = "Mode"; Value = $HALBSSLMode; }) > $Null                                                                           $ScriptInformation.Add(@{Data = ""; Value = "$item"; }) > $Null
                                        If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")                                                                   }
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsFolderExclusionList.Count -eq 0)
                                        {                                                   {
                                                            $ScriptInformation.Add(@{Data = "          Folder Exclusion List"; Value = "None"; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                $ScriptInformation.Add(@{Data = "Security"; Value = ""; }) > $Null                                                           $ScriptInformation.Add(@{Data = "          Folder Exclusion List"; Value = ""; }) > $Null
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    Switch($item.ExcludeFolderCopy)
                                                                    {
                                                                            "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}
                                                                            "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}
                                                                            "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}
                                                                            "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}
                                                                            Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}
                                                                    }
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = "               Folder"; Value = "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"; }) > $Null
                                                                    }
                                                            }
                                                    }
                                                    
                                                    $ScriptInformation.Add(@{Data = "     Advanced"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          FSLogix Setting:"; Value = "Value:"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Access network as computer object"; Value = "$($FSLogixAS_AccessNetworkAsComputerObject)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Custom SDDL for profile directory"; Value = "$($FSLogixAS_ProfileDirSDDL)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Delay between locked VHD(X) retries"; Value = "$($FSLogixAS_LockedRetryInterval)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Delete local profile when loading from VHD"; Value = "$($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Diff disk parent folder path"; Value = "$($FSLogixAS_DiffDiskParentFolderPath)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Do not create a folder for new profiles"; Value = "$($FSLogixAS_NoProfileContainingFolder)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Enable Cached mode for Outlook"; Value = "$($FSLogixAS_OutlookCachedMode)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Keep local profiles"; Value = "$($FSLogixAS_KeepLocalDir)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Naming pattern for new VHD(X) files"; Value = "$($FSLogixAS_VHDNamePattern)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Accepted SSL Versions"; Value = $HALBSSLAcceptedSSLVersions; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          Number of locked VHD(X) retries"; Value = "$($FSLogixAS_LockedRetryCount)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Prevent logons with failures"; Value = "$($FSLogixAS_PreventLoginWithFailure)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Prevent logons with temp profiles"; Value = "$($FSLogixAS_PreventLoginWithTempProfile)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Cipher Strength"; Value = $HALBSSLCipherStrength; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          Profile folder naming pattern"; Value = "$($FSLogixAS_SIDDirNameMatch)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Cipher"; Value = $HALBSSLCipher; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          Profile type"; Value = "$($FSLogixAS_ProfileType)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Profile VHD(X) file matching pattern"; Value = "$($FSLogixAS_VHDNameMatch)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Re-attach interval"; Value = "$($FSLogixAS_ReAttachIntervalSeconds)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Re-attach retry limit"; Value = "$($FSLogixAS_ReAttachRetryCount)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Remove duplicate OST files on logoff"; Value = "$($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          SDDL used when attaching the VHD"; Value = "$($FSLogixAS_AttachVHDSDDL)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Search roaming feature mode"; Value = "$($FSLogixAS_RoamSearch)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Swap SID and username in profile directory names"; Value = "$($FSLogixAS_FlipFlopProfileDirectoryName)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Use ciphers according to server preference"; Value = $HALBSSLUseServerPreference; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          Temporary folders redirection mode"; Value = "$($FSLogixAS_SetTempToLocalPath)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Use SDDL on creation of SID containing folder"; Value = "$($FSLogixAS_SIDDirSDDL)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          User-to-Profile matching pattern"; Value = "$($FSLogixAS_SIDDirNamePattern)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Certificates"; Value = $HALBSSLCertificates; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          VHDX sector size"; Value = "$($FSLogixAS_VHDXSectorSize)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Volume wait time"; Value = "$($FSLogixAS_VolumeWaitTimeMS)"; }) > $Null
 
                                        $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 250;
 
                                        Line 3 "Port: " $HALBSSLGatewayPort <>                                         Line 3 "Inherit default settings`t`t`t`t: " $VDITemplate.InheritDefaultUserProfileSettings.ToString()
                                        Line 3 "Mode: " $HALBSSLMode                                           Line 3 "Technology`t`t`t`t`t`t: " $TemplateTechnology
                                        If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")    
                                            If($TemplateTechnology -eq "Do not manage by RAS")
 
  <>                                                 #do nothing
                                            }
                                            ElseIf($TemplateTechnology -eq "FSLogix")
                                            {
                                                    Line 3 "Deployment method`t`t`t`t`t: " $FSLogixDeploymentSettingsDeploymentMethod
                                                    If($FSLogixDeploymentSettings.InstallType -eq "Online")
                                                    {
                                                            Line 3 "URL`t`t`t`t`t`t`t: " $FSLogixDeploymentSettingsInstallOnlineURL
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                                                    {
                                                            Line 10 ": " $FSLogixDeploymentSettingsNetworkDrivePath
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                                                    {
                                                            Line 10 ": " $FSLogixDeploymentSettingsInstallerFileName
                                                    }
                                                    Line 3 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()
                                                Line 3 "Security"                                                   Line 3 "Settings"
                                                Line 4 "Accepted SSL Versions`t`t`t`t: " $HALBSSLAcceptedSSLVersions    
                                                Line 4 "Cipher Strength`t`t`t`t`t: " $HALBSSLCipherStrength                                                   Line 4 "Location type`t`t`t`t`t: " $FSLogixLocationType
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $FSLogixLocationOfProfileDisks)
                                                    {
                                                            $cnt++
                                                            
                                                            If($cnt -eq 0)
                                                            {
                                                                    Line 4 "Location of profile disks`t`t`t: " $item
                                                            }
                                                            Else
                                                            {
                                                                    Line 10 "  " $item
                                                            }
                                                    }
                                                    Line 4 "Profile disk format`t`t`t`t: " $FSLogixProfileDiskFormat
                                                Line 4 "Cipher`t`t`t`t`t`t: " $HALBSSLCipher                                                   Line 4 "Allocation type`t`t`t`t`t: " $FSLogixAllocationType
                                                Line 4 "Use ciphers according to server preference`t: " $HALBSSLUseServerPreference    
                                                Line 4 "Certificates`t`t`t`t`t: " $HALBSSLCertificates                                                   Line 4 "Default size`t`t`t`t`t: " "$FSLogixDefaultSize GB"
                                                    Line 3 "Additional settings"
                                                    Line 4 "Users and Groups"
                                                    
                                                    If($FSLogixSettingsUserInclusionList.Count -eq 0)
                                                    {
                                                            Line 5 "User Inclusion List`t`t`t: " "None"
                                                    }
                                                    Else
                                                    {
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            Line 5 "User Inclusion List`t`t`t: " "User: $($item.Account)  Type: $($item.Type)"
                                                                    }
                                                                    Else
                                                                    {
                                                                            Line 10 "  " "User: $($item.Account)  Type: $($item.Type)"
                                                                    }
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsUserExclusionList.Count -eq 0)
                                                    {
                                                            Line 5 "User Exclusion List`t`t`t: " "None"
                                                    }
                                                    Else
                                                    {
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            Line 5 "User Exclusion List`t`t`t: " "User: $($item.Account)  Type: $($item.Type)"
                                                                    }
                                                                    Else
                                                                    {
                                                                            Line 10 "  " "User: $($item.Account)  Type: $($item.Type)"
                                                                    }
                                                            }
                                                    }
                                                    Line 4 "Folders"
                                                    Line 5 "Customize profile folders`t`t: " $FSLogixSettingsCustomizeProfileFolders.ToString()
                                                    If($FSLogixSettingsCustomizeProfileFolders)
                                                    {
                                                            If($ExcludedCommonFolders.Count -gt 0)
                                                            {
                                                                    $cnt = -1
                                                                    ForEach($item in $ExcludedCommonFolders)
                                                                    {
                                                                            $cnt++
                                                                            
                                                                            If($cnt -eq 0)
                                                                            {
                                                                                    Line 6 "Exclude Common Folders`t`t: " $item
                                                                            }
                                                                            Else
                                                                            {
                                                                                    Line 10 "  " $item
                                                                            }
                                                                    }
                                                            }
                                                            Else
                                                            {
                                                                    Line 6 "Exclude Common Folders`t`t: None"
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsFolderInclusionList.Count -eq 0)
                                                    {
                                                            Line 5 "Folder Inclusion List`t`t`t: " "None"
                                                    }
                                                    Else
                                                    {
                                                            Line 5 "Folder Inclusion List"
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            Line 6 "Folder`t`t`t`t: " $item
                                                                    }
                                                                    Else
                                                                    {
                                                                            Line 10 "  " $item
                                                                    }
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsFolderExclusionList.Count -eq 0)
                                                    {
                                                            Line 5 "Folder Exclusion List`t`t`t: " "None"
                                                    }
                                                    Else
                                                    {
                                                            Line 5 "Folder Exclusion List"
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    Switch($item.ExcludeFolderCopy)
                                                                    {
                                                                            "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}
                                                                            "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}
                                                                            "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}
                                                                            "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}
                                                                            Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}
                                                                    }
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            Line 6 "Folder`t`t`t`t: " "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"
                                                                    }
                                                                    Else
                                                                    {
                                                                            Line 10 "  " "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"
                                                                    }
                                                            }
                                                    }
                                                    
                                                    Line 4 "Advanced"
                                                    Line 5 "FSLogix Setting                                      Value"
                                                    Line 5 "======================================================================================"
                                                    #      "Swap SID and username in profile directory names     Redirect TEMP, TMP, and INetCache"
                                                    Line 5 "Access network as computer object                    $($FSLogixAS_AccessNetworkAsComputerObject)"
                                                    Line 5 "Custom SDDL for profile directory                    $($FSLogixAS_ProfileDirSDDL)"
                                                    Line 5 "Delay between locked VHD(X) retries                  $($FSLogixAS_LockedRetryInterval)"
                                                    Line 5 "Delete local profile when loading from VHD           $($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)"
                                                    Line 5 "Diff disk parent folder path                         $($FSLogixAS_DiffDiskParentFolderPath)"
                                                    Line 5 "Do not create a folder for new profiles              $($FSLogixAS_NoProfileContainingFolder)"
                                                    Line 5 "Enable Cached mode for Outlook                       $($FSLogixAS_OutlookCachedMode)"
                                                    Line 5 "Keep local profiles                                  $($FSLogixAS_KeepLocalDir)"
                                                    Line 5 "Naming pattern for new VHD(X) files                  $($FSLogixAS_VHDNamePattern)"
                                                    Line 5 "Number of locked VHD(X) retries                      $($FSLogixAS_LockedRetryCount)"
                                                    Line 5 "Prevent logons with failures                         $($FSLogixAS_PreventLoginWithFailure)"
                                                    Line 5 "Prevent logons with temp profiles                    $($FSLogixAS_PreventLoginWithTempProfile)"
                                                    Line 5 "Profile folder naming pattern                        $($FSLogixAS_SIDDirNameMatch)"
                                                    Line 5 "Profile type                                         $($FSLogixAS_ProfileType)"
                                                    Line 5 "Profile VHD(X) file matching pattern                 $($FSLogixAS_VHDNameMatch)"
                                                    Line 5 "Re-attach interval                                   $($FSLogixAS_ReAttachIntervalSeconds)"
                                                    Line 5 "Re-attach retry limit                                $($FSLogixAS_ReAttachRetryCount)"
                                                    Line 5 "Remove duplicate OST files on logoff                 $($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)"
                                                    Line 5 "SDDL used when attaching the VHD                     $($FSLogixAS_AttachVHDSDDL)"
                                                    Line 5 "Search roaming feature mode                          $($FSLogixAS_RoamSearch)"
                                                    Line 5 "Swap SID and username in profile directory names     $($FSLogixAS_FlipFlopProfileDirectoryName)"
                                                    Line 5 "Temporary folders redirection mode                   $($FSLogixAS_SetTempToLocalPath)"
                                                    Line 5 "Use SDDL on creation of SID containing folder        $($FSLogixAS_SIDDirSDDL)"
                                                    Line 5 "User-to-Profile matching pattern                     $($FSLogixAS_SIDDirNamePattern)"
                                                    Line 5 "VHDX sector size                                     $($FSLogixAS_VHDXSectorSize)"
                                                    Line 5 "Volume wait time                                     $($FSLogixAS_VolumeWaitTimeMS)"
 
  -+  
 
  <>                                         $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefaultUserProfileSettings.ToString(),$htmlwhite)
                                            $rowdata += @(,("Technology",($Script:htmlsb),$TemplateTechnology,$htmlwhite))
     
                                            If($TemplateTechnology -eq "Do not manage by RAS")
                                            {
                                                    #do nothing
                                            }
                                            ElseIf($TemplateTechnology -eq "FSLogix")
                                            {
                                                    $rowdata += @(,("Deployment method",($Script:htmlsb),$FSLogixDeploymentSettingsDeploymentMethod,$htmlwhite))
                                                    If($FSLogixDeploymentSettings.InstallType -eq "Online")
                                                    {
                                                            $rowdata += @(,("URL",($Script:htmlsb),$FSLogixDeploymentSettingsInstallOnlineURL,$htmlwhite))
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                                                    {
                                        $columnHeaders = @("Port",($Script:htmlsb),$HALBSSLGatewayPort,$htmlwhite)                                                           $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsNetworkDrivePath,$htmlwhite))
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsInstallerFileName,$htmlwhite))
                                                    }
                                                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))
                                                    $rowdata += @(,("Settings",($Script:htmlsb),"",$htmlwhite))
                                                    $rowdata += @(,("     Location type",($Script:htmlsb),$FSLogixLocationType,$htmlwhite))
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $FSLogixLocationOfProfileDisks)
                                                    {
                                                            $cnt++
                                                            
                                                            If($cnt -eq 0)
                                                            {
                                                                    $rowdata += @(,("     Location of profile disks",($Script:htmlsb),$item,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                        $rowdata += @(,("Mode",($Script:htmlsb),$HALBSSLMode,$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))
                                        If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")                                                           }
                                                    }
                                                    $rowdata += @(,("     Profile disk format",($Script:htmlsb),$FSLogixProfileDiskFormat,$htmlwhite))
                                                    $rowdata += @(,("     Allocation type",($Script:htmlsb),$FSLogixAllocationType,$htmlwhite))
                                                    $rowdata += @(,("     Default size",($Script:htmlsb),"$FSLogixDefaultSize GB",$htmlwhite))
                                                    $rowdata += @(,("Additional settings",($Script:htmlsb),"",$htmlwhite))
                                                    $rowdata += @(,("     Users and Groups",($Script:htmlsb),"",$htmlwhite))
                                                    
                                                    If($FSLogixSettingsUserInclusionList.Count -eq 0)
                                        {                                                   {
                                                            $rowdata += @(,("          User Inclusion List",($Script:htmlsb),"None",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("          User Inclusion List",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))
                                                $rowdata += @(,( "Security",($Script:htmlsb), "",$htmlwhite))                                                                           $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                                    }
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsUserExclusionList.Count -eq 0)
                                                    {
                                                $rowdata += @(,( "     Accepted SSL Versions",($Script:htmlsb), $HALBSSLAcceptedSSLVersions,$htmlwhite))                                                           $rowdata += @(,("          User Exclusion List",($Script:htmlsb),"None",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("          User Exclusion List",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                                    }
                                                            }
                                                    }
                                                    $rowdata += @(,("     Folders",($Script:htmlsb),"",$htmlwhite))
                                                    $rowdata += @(,("          Customize profile folders",($Script:htmlsb),$FSLogixSettingsCustomizeProfileFolders.ToString(),$htmlwhite))
                                                    If($FSLogixSettingsCustomizeProfileFolders)
                                                    {
                                                            If($ExcludedCommonFolders.Count -gt 0)
                                                            {
                                                                    $cnt = -1
                                                                    ForEach($item in $ExcludedCommonFolders)
                                                                    {
                                                                            $cnt++
                                                                            
                                                                            If($cnt -eq 0)
                                                                            {
                                                                                    $rowdata += @(,("               Exclude Common Folders",($Script:htmlsb),$item,$htmlwhite))
                                                                            }
                                                                            Else
                                                                            {
                                                $rowdata += @(,( "     Cipher Strength",($Script:htmlsb), $HALBSSLCipherStrength,$htmlwhite))                                                                                   $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))
                                                                            }
                                                                    }
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("               Exclude Common Folders",($Script:htmlsb),"None",$htmlwhite))
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsFolderInclusionList.Count -eq 0)
                                                    {
                                                            $rowdata += @(,("          Folder Inclusion List",($Script:htmlsb),"None",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("          Folder Inclusion List",($Script:htmlsb),"",$htmlwhite))
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("               Folder",($Script:htmlsb),"$item",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                $rowdata += @(,( "     Cipher",($Script:htmlsb), $HALBSSLCipher,$htmlwhite))                                                                           $rowdata += @(,("",($Script:htmlsb),"$item",$htmlwhite))
                                                                    }
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsFolderExclusionList.Count -eq 0)
                                                    {
                                                            $rowdata += @(,("          Folder Exclusion List",($Script:htmlsb),"None",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("          Folder Exclusion List",($Script:htmlsb),"",$htmlwhite))
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    Switch($item.ExcludeFolderCopy)
                                                                    {
                                                                            "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}
                                                                            "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}
                                                                            "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}
                                                                            "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}
                                                                            Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}
                                                                    }
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("               Folder",($Script:htmlsb),"$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb),"$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack",$htmlwhite))
                                                                    }
                                                            }
                                                    }
     
                                                    $rowdata += @(,("     Advanced",($Script:htmlsb),"",$htmlwhite))
                                                    $rowdata += @(,("          FSLogix Setting:",($Script:htmlsb),"Value:",$htmlwhite))
                                                    $rowdata += @(,("          Access network as computer object",($Script:htmlsb),"$($FSLogixAS_AccessNetworkAsComputerObject)",$htmlwhite))
                                                    $rowdata += @(,("          Custom SDDL for profile directory",($Script:htmlsb),"$($FSLogixAS_ProfileDirSDDL)",$htmlwhite))
                                                    $rowdata += @(,("          Delay between locked VHD(X) retries",($Script:htmlsb),"$($FSLogixAS_LockedRetryInterval)",$htmlwhite))
                                                    $rowdata += @(,("          Delete local profile when loading from VHD",($Script:htmlsb),"$($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)",$htmlwhite))
                                                    $rowdata += @(,("          Diff disk parent folder path",($Script:htmlsb),"$($FSLogixAS_DiffDiskParentFolderPath)",$htmlwhite))
                                                    $rowdata += @(,("          Do not create a folder for new profiles",($Script:htmlsb),"$($FSLogixAS_NoProfileContainingFolder)",$htmlwhite))
                                                    $rowdata += @(,("          Enable Cached mode for Outlook",($Script:htmlsb),"$($FSLogixAS_OutlookCachedMode)",$htmlwhite))
                                                    $rowdata += @(,("          Keep local profiles",($Script:htmlsb),"$($FSLogixAS_KeepLocalDir)",$htmlwhite))
                                                    $rowdata += @(,("          Naming pattern for new VHD(X) files",($Script:htmlsb),"$($FSLogixAS_VHDNamePattern)",$htmlwhite))
                                                    $rowdata += @(,("          Number of locked VHD(X) retries",($Script:htmlsb),"$($FSLogixAS_LockedRetryCount)",$htmlwhite))
                                                    $rowdata += @(,("          Prevent logons with failures",($Script:htmlsb),"$($FSLogixAS_PreventLoginWithFailure)",$htmlwhite))
                                                    $rowdata += @(,("          Prevent logons with temp profiles",($Script:htmlsb),"$($FSLogixAS_PreventLoginWithTempProfile)",$htmlwhite))
                                                    $rowdata += @(,("          Profile folder naming pattern",($Script:htmlsb),"$($FSLogixAS_SIDDirNameMatch)",$htmlwhite))
                                                    $rowdata += @(,("          Profile type",($Script:htmlsb),"$($FSLogixAS_ProfileType)",$htmlwhite))
                                                    $rowdata += @(,("          Profile VHD(X) file matching pattern",($Script:htmlsb),"$($FSLogixAS_VHDNameMatch)",$htmlwhite))
                                                    $rowdata += @(,("          Re-attach interval",($Script:htmlsb),"$($FSLogixAS_ReAttachIntervalSeconds)",$htmlwhite))
                                                    $rowdata += @(,("          Re-attach retry limit",($Script:htmlsb),"$($FSLogixAS_ReAttachRetryCount)",$htmlwhite))
                                                    $rowdata += @(,("          Remove duplicate OST files on logoff",($Script:htmlsb),"$($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)",$htmlwhite))
                                                    $rowdata += @(,("          SDDL used when attaching the VHD",($Script:htmlsb),"$($FSLogixAS_AttachVHDSDDL)",$htmlwhite))
                                                    $rowdata += @(,("          Search roaming feature mode",($Script:htmlsb),"$($FSLogixAS_RoamSearch)",$htmlwhite))
                                                    $rowdata += @(,("          Swap SID and username in profile directory names",($Script:htmlsb),"$($FSLogixAS_FlipFlopProfileDirectoryName)",$htmlwhite))
                                                $rowdata += @(,( "     Use ciphers according to server preference",($Script:htmlsb), $HALBSSLUseServerPreference,$htmlwhite))                                                   $rowdata += @(,("          Temporary folders redirection mode",($Script:htmlsb),"$($FSLogixAS_SetTempToLocalPath)",$htmlwhite))
                                                    $rowdata += @(,("          Use SDDL on creation of SID containing folder",($Script:htmlsb),"$($FSLogixAS_SIDDirSDDL)",$htmlwhite))
                                                    $rowdata += @(,("          User-to-Profile matching pattern",($Script:htmlsb),"$($FSLogixAS_SIDDirNamePattern)",$htmlwhite))
                                                $rowdata += @(,( "     Certificates",($Script:htmlsb), $HALBSSLCertificates,$htmlwhite))                                                   $rowdata += @(,("          VHDX sector size",($Script:htmlsb),"$($FSLogixAS_VHDXSectorSize)",$htmlwhite))
                                                    $rowdata += @(,("          Volume wait time",($Script:htmlsb),"$($FSLogixAS_VolumeWaitTimeMS)",$htmlwhite))
 
                                        $msg = "" <>                                         $msg = "User profile"
                                        $columnWidths = @("200","400")                                           $columnWidths = @("350","325")
 
  -+                                 #>
 
                                #second, process the gateways <>                                 #Optimization
                                #do output headers                                  
 
                                        [System.Collections.Hashtable[]] $GatewaysWordTable = @(); <>                                         WriteWordLine 4 0 "Optimization"
 
                                        Line 3 "Gateways                                                 Status                                  " <>                                         Line 2 "Optimization"
                                        Line 3 "================================================================================================="    
                                        #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890    
                                        #       1234567890123456789012345678901234567890123456789012345    
 
                                        $rowdata = @() <>                                         #Nothing
 
  <>  
                                    If($VDITemplate.InheritDefaultOptimizationSettings)
                                    {
                                            #do we inherit site defaults?
                                            #http://woshub.com/hot-to-convert-sid-to-username-and-vice-versa/
                                            #for translating the User SID to the AD user name
                                            #yes we do, get the default settings for the Site
                                            #use the Site default settings
                                            $VDIDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                                                          
                                #process the gateways data                                           If($? -and $Null -ne $VDIDefaults)
                                ForEach($GWItem in $HALBSSLGateways)                                           {
                                                    $OPTEnableOptimization            = $VDIDefaults.Optimization.EnableOptimization.ToString()
                                                    $OPTOptimizationType              = $VDIDefaults.Optimization.OptimizationType.ToString()
                                                    $OPTWindowsDefenderATPEnabled     = $VDIDefaults.Optimization.WindowsDefenderATPEnabled.ToString()    
                                                    $OPTWindowsComponentsEnabled      = $VDIDefaults.Optimization.WindowsComponentsEnabled.ToString()
                                                    $OPTWindowsServicesEnabled        = $VDIDefaults.Optimization.WindowsServicesEnabled.ToString()
                                                    $OPTWinodwsScheduledTasksEnabled  = $VDIDefaults.Optimization.WindowsScheduledTasksEnabled.ToString()
                                                    $OPTWindowsAdvancedOptionsEnabled = $VDIDefaults.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                                    $OPTNetworkPerformanceEnabled     = $VDIDefaults.Optimization.NetworkPerformanceEnabled.ToString()
                                                    $OPTRegistryEnabled               = $VDIDefaults.Optimization.RegistryEnabled.ToString()
                                                    $OPTVisualEffectsEnabled          = $VDIDefaults.Optimization.VisualEffectsEnabled.ToString()   
                                                    $OPTDiskCleanupEnabled            = $VDIDefaults.Optimization.DiskCleanupEnabled.ToString()
                                                    $OPTCustomScriptEnabled           = $VDIDefaults.Optimization.CustomScriptEnabled.ToString()
                                            }
                                            Else
                                            {
                                                    #unable to retrieve default, use built-in default values
                                                    $OPTEnableOptimization            = "False"
                                                    $OPTOptimizationType              = ""
                                                    $OPTWindowsDefenderATPEnabled     = "False"
                                                    $OPTWindowsComponentsEnabled      = "False"
                                                    $OPTWindowsServicesEnabled        = "False"
                                                    $OPTWinodwsScheduledTasksEnabled  = "False"
                                                    $OPTWindowsAdvancedOptionsEnabled = "False"
                                                    $OPTNetworkPerformanceEnabled     = "False"
                                                    $OPTRegistryEnabled               = "False"
                                                    $OPTVisualEffectsEnabled          = "False"
                                                    $OPTDiskCleanupEnabled            = "False"
                                                    $OPTCustomScriptEnabled           = "False"
                                            }
                                    }
                                    Else
 
                                        $ip = $GWItem.Keys <>                                         #we don't inherit
                                        $Results = [System.Net.Dns]::gethostentry($ip)                                           #get the settings for the template
                                        $hostname = $Results.HostName    
                                        $TempGW = Get-RASGWStatus -Server $hostname -EA 0 4> $Null    
                                        $HALBGWStatus = GetRASStatus $TempGW.AgentState    
 
  <>                                         $OPTEnableOptimization            = $VDITemplate.Optimization.EnableOptimization.ToString()
                                            $OPTOptimizationType              = $VDITemplate.Optimization.OptimizationType.ToString()
                                            $OPTWindowsDefenderATPEnabled     = $VDITemplate.Optimization.WindowsDefenderATPEnabled.ToString()    
                                            $OPTWindowsComponentsEnabled      = $VDITemplate.Optimization.WindowsComponentsEnabled.ToString()
                                            $OPTWindowsServicesEnabled        = $VDITemplate.Optimization.WindowsServicesEnabled.ToString()
                                            $OPTWinodwsScheduledTasksEnabled  = $VDITemplate.Optimization.WindowsScheduledTasksEnabled.ToString()
                                            $OPTWindowsAdvancedOptionsEnabled = $VDITemplate.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                            $OPTNetworkPerformanceEnabled     = $VDITemplate.Optimization.NetworkPerformanceEnabled.ToString()
                                            $OPTRegistryEnabled               = $VDITemplate.Optimization.RegistryEnabled.ToString()
                                            $OPTVisualEffectsEnabled          = $VDITemplate.Optimization.VisualEffectsEnabled.ToString()   
                                            $OPTDiskCleanupEnabled            = $VDITemplate.Optimization.DiskCleanupEnabled.ToString()
                                            $OPTCustomScriptEnabled           = $VDITemplate.Optimization.CustomScriptEnabled.ToString()
                                    }
     
                                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultUserProfileSettings.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Enable optimization"; Value = $OPTEnableOptimization; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Optimization type"; Value = $OPTOptimizationType; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 250;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            WriteWordLine 5 0 "Windows Defender ATP:" $OPTWindowsDefenderATPEnabled
                                            If($OPTWindowsDefenderATPEnabled -eq "True")
 
  <>                                                 $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Windows Defender ATP Optimizations"; Value = ""; }) > $Null
     
                                                    If($VDITemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                                    {
                                                            $ScriptInformation.Add(@{Data = "     Turn off Windows Defender ATP (I use my own ATP solution)"; Value = ""; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = "     Turn on Windows Defender ATP and set process and folder exclusions"; Value = ""; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "     Disable real-time protection"; Value = $VDITemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(); }) > $Null
                                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                            
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = "     Exclude files and folders"; Value = $item; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                    }
                                                            }
     
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = "     Exclude processes"; Value = $item; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                    }
                                                            }
                                                            
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = "     Exclude extensions"; Value = $item; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                    }
                                                            }
                                                    }
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                $GatewaysWordTableRowHash = @{                                                   -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 250;
                                                    $Table.Columns.Item(2).Width = 250;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
     
                                            WriteWordLine 5 0 "Windows Components:" $OPTWindowsComponentsEnabled
                                            If($OPTWindowsComponentsEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Windows Components Optimizations"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Disable (remove) components:"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    ForEach($item in $VDITemplate.Optimization.WindowsComponents.WindowsComponentsList)
                                                    {
                                                                    If($Null -eq $item.DisplayName)
                                                                    {
                                                        Gateway       = "$hostname ($ip)";                                                                           $DisplayName = ""
                                                        GatewayStatus = $HALBGWStatus;                                                                   }
                                                                    Else
                                                                    {
                                                                            $DisplayName = $item.DisplayName
                                                                    }
                                                                    If($Null -eq $item.ComponentName)
                                                                    {
                                                                            $ComponentName = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ComponentName = $item.ComponentName
                                                                    }
                                                            $OptimizationTable += @{
                                                                    DisplayName = $DisplayName
                                                                    ComponentName = $ComponentName
                                                            }
 
  <>  
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                $GatewaysWordTable += $GatewaysWordTableRowHash                                                           $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns DisplayName, ComponentName `
                                                            -Headers "Display name", "Component" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 200;
                                                            $Table.Columns.Item(2).Width = 200;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
 
  <>  
                                            WriteWordLine 5 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                            If($OPTWindowsServicesEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Windows Services Optimizations"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Disable services:"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    ForEach($item in $VDITemplate.Optimization.WindowsServices.WindowsServicesList)
                                                    {
                                                                    If($Null -eq $item.DisplayName)
                                                                    {
                                                                            $DisplayName = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $DisplayName = $item.DisplayName
                                                                    }
                                                                    If($Null -eq $item.ServiceName)
                                                                    {
                                                                            $Service = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $Service = $item.ServiceName
                                                                    }
                                                                    If($Null -eq $item.Aliases)
                                                                    {
                                                                            $Aliases = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $Aliases = $item.Aliases
                                                                    }
                                                            $OptimizationTable += @{
                                                                    DisplayName = $DisplayName
                                                                    Service     = $Service
                                                                    Aliases     = $Aliases
                                                            }
                                                    }
     
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                            $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns DisplayName, Service, Aliases `
                                                            -Headers "Display name", "Service", "Aliases" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 200;
                                                            $Table.Columns.Item(2).Width = 100;
                                                            $Table.Columns.Item(3).Width = 50;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
                                            
                                            WriteWordLine 5 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                            If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Windows Scheduled Tasks Optimizations"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Disable tasks:"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    ForEach($item in $VDITemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                                    {
                                        If($Text)                                                                   If($Null -eq $item.Task)
                                        {                                                                   {
                                                Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)                                                                           $Task = ""
                                        }                                                                   }
                                                                    Else
                                                                    {
                                                                            $Task = $item.Task
                                                                    }
                                                                    If($Null -eq $item.Type)
                                                                    {
                                                                            $Type = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $Type = $item.Type.ToString()
                                                                    }
                                                                    If($Null -eq $item.Location)
                                                                    {
                                                                            $Location = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $Location = $item.Location
                                                                    }
                                                            $OptimizationTable += @{
                                                                    Task     = $Task
                                                                    Type     = $Type
                                                                    Location = $Location
                                                            }
                                                    }
                                        If($HTML)    
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                            $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns Task, Type, Location `
                                                            -Headers "Task", "Type", "Location" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 200;
                                                            $Table.Columns.Item(2).Width = 50;
                                                            $Table.Columns.Item(3).Width = 250;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
                                            
                                            WriteWordLine 5 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                            If($OPTWindowsAdvancedOptionsEnabled -eq "True")
 
                                                $rowdata += @(,( <>                                                 $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Windows Advanced Options"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                "$hostname ($ip)",$htmlwhite,                                                   $OptimizationTable = @()
                                                $HALBGWStatus,$htmlwhite))                          
                                                    $OptimizationTable += @{
                                                            Setting = "Disable Hibernate"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString()
                                                            Value   = ""
                                        }                                                   }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable Telemetry collection"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString()
                                                            Value   = ""
                                }                                                   }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable System Restore"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable error reporting to send additional data"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable Tiles"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable Cortana digital assistant"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Turn off Microsoft consumer experience"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Do not show Windows tips"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Remove Common program groups from the Start Menu"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Partial Start Menu layout"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString()
                                                            Value   = $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent
                                                    }
     
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                            $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns Setting, Enabled, Value `
                                                            -Headers "Setting", "Enabled", "Value" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 275;
                                                            $Table.Columns.Item(2).Width = 50;
                                                            $Table.Columns.Item(3).Width = 175;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
                                                                          
                                #output the Word/PDF and HTML tables                                           WriteWordLine 5 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                If($MSWord -or $PDF)                                           If($OPTNetworkPerformanceEnabled -eq "True")
                                {                                           {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Network Performance Optimizations"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    $OptimizationTable += @{
                                                            Setting = "FileInfoCacheEntriesMax"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString()
                                                            Value   = $VDITemplate.Optimization.NetworkPerformance.FileInfoCache
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "DirectoryCacheEntriesMax"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString()
                                                            Value   = $VDITemplate.Optimization.NetworkPerformance.DirCacheMax
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "FileNotFoundCacheEntriesMax"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString()
                                                            Value   = $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCache
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "DormantFileLimit"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString()
                                                            Value   = $VDITemplate.Optimization.NetworkPerformance.DormantFileLimit
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable TCP/IP Task Offload"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableTCP.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable IPv6 Components"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable IPv6 to IPv4"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disables isatap for IPv6"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString()
                                                            Value   = ""
                                                    }
     
                                        If($GatewaysWordTable.Count -gt 0)                                                   If($OptimizationTable.Count -gt 0)
                                        {                                                   {
                                                $Table = AddWordTable -Hashtable $GatewaysWordTable `                                                           $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns Setting, Enabled, Value `
                                                            -Headers "Setting", "Enabled", "Value" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 150;
                                                            $Table.Columns.Item(2).Width = 50;
                                                            $Table.Columns.Item(3).Width = 50;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
     
                                            WriteWordLine 5 0 "Registry: " $OPTRegistryEnabled
                                            If($OPTRegistryEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Registry Optimizations"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
     
                                                    ForEach($item in $VDITemplate.Optimization.Registry.RegistryList)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Data"; Value = $item.DWORDValue; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null
                                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                    }
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                -Columns  Gateway,GatewayStatus `                                                   -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 125;
                                                    $Table.Columns.Item(2).Width = 375;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                            
                                            WriteWordLine 5 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                            If($OPTVisualEffectsEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Visual Effects Optimizations"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    $OptimizationTable += @{
                                                            Setting = "Animate controls and elements inside windows"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Animate windows when minimizing and maximizing"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Animations in the taskbar"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.AnimateTaskbar.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Enable Peek"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.EnablePeek.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Fade or slide menus into view"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.FadeSlideMenus.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Fade or slide Tooltips into view"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Fade out menu items after clicking"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Save taskbar thumbnail previews"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Show shadows under mouse pointer"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Show shadows under windows"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Show thumbnails instead of icons"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Show translucent selection rectangle"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Show window contents while dragging"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Slide open combo boxes"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Smooth edges of screen fonts"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Smooth-scroll list boxes"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Use drop shadows for icon labels on the desktop"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.DropShadowsIcon.ToString()
                                                    }
     
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                            $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns Setting, Enabled `
                                                -Headers  "Gateways","Status"`                                                           -Headers "Setting", "Enabled" `
                                                -Format $wdTableGrid `                                                           -Format $wdTableGrid `
                                                -AutoFit $wdAutoFitFixed;                                                           -AutoFit $wdAutoFitFixed;
 
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15; <>                                                         SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
  -+                                                         $Table.Columns.Item(1).Width = 250;
                                                            $Table.Columns.Item(2).Width = 50;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
                                            
                                            WriteWordLine 5 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                            If($OPTDiskCleanupEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Disk Cleanup Optimizations"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
 
  <>                                                 $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    $OptimizationTable += @{
                                                            Setting = "Clean up redundant system files"
                                                            Enabled = $VDITemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Clean up the WinSxS Folder"
                                                            Enabled = $VDITemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Clean up temporary files and logs"
                                                            Enabled = $VDITemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Remove OneDrive"
                                                            Enabled = $VDITemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Delete users' profiles"
                                                            Enabled = $VDITemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString()
                                                    }
     
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                            $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns Setting, Enabled `
                                                            -Headers "Setting", "Enabled" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 175;
                                                $Table.Columns.Item(2).Width = 250;                                                           $Table.Columns.Item(2).Width = 50;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
     
                                            WriteWordLine 5 0 "Custom script: " $OPTCustomScriptEnabled
                                            If($OPTCustomScriptEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Custom Script"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Command"; Value = $VDITemplate.Optimization.CustomScript.Command; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Arguments"; Value = $VDITemplate.Optimization.CustomScript.Arguments; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Initial directory"; Value = $VDITemplate.Optimization.CustomScript.InitDir; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Username"; Value = $VDITemplate.Optimization.CustomScript.User; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 100;
                                                    $Table.Columns.Item(2).Width = 200;
 
  -+                                         Line 3 "Inherit default settings`t: " $VDITemplate.InheritDefaultOptimizationSettings.ToString()
                                            Line 3 "Enable optimization`t`t: " $OPTEnableOptimization
                                            Line 3 "Optimization type`t`t: " $OPTOptimizationType
                                            Line 3 "Category"
                                            
                                            Line 4 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                            If($OPTWindowsDefenderATPEnabled -eq "True")
                                            {
                                                    Line 5 "Windows Defender ATP Optimizations"
                                                    If($VDITemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                                    {
                                                            Line 6 "Turn off Windows Defender ATP (I use my own ATP solution)"
                                                    }
                                                    Else
                                                    {
                                                            Line 6 "Turn on Windows Defender ATP and set process and folder exclusions"
                                                            Line 6 "Disable real-time protection: " $VDITemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString()
                                                            Line 0 ""
                                                            Line 6 "Exclude files and folders:"
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                            {
                                                                    Line 7 $item
                                                            }
     
                                                            Line 6 "Exclude processes:"
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                            {
                                                                    Line 7 $item
                                                            }
                                                            
                                                            Line 6 "Exclude extensions:"
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                            {
                                                                    Line 7 $item
                                                            }
                                                    }
                                                    
                                                    Line 0 ""
                                            }
                                            
                                            Line 4 "Windows Components: " $OPTWindowsComponentsEnabled
                                            If($OPTWindowsComponentsEnabled -eq "True")
                                            {
                                                    Line 5 "Windows Components Optimizations"
                                                    Line 6 "Disable (remove) components:"
                                                    Line 0 ""
                                                    Line 6 "Display name                                        Component                                         "
                                                    Line 6 "======================================================================================================"
                                                    #               12345678901234567890123456789012345678901234567890SS12345678901234567890123456789012345678901234567890
                                                    #               Printing-XPSServices-Features                       SMB 1.0/CIFS File sharing support component
                                                    ForEach($item in $VDITemplate.Optimization.WindowsComponents.WindowsComponentsList)
                                                    {
                                                            Line 6 ( "{0,-50}  {1,-50}" -f $item.DisplayName, $item.ComponentName)
                                                    }
                                                    Line 0 ""
                                            }
                                            
                                            Line 4 "Windows Services: " $OPTWindowsServicesEnabled       
                                            If($OPTWindowsServicesEnabled -eq "True")
                                            {
                                                    Line 5 "Windows Services Optimizations"
                                                    Line 6 "Disable services:"
                                                    Line 0 ""
                                                    Line 6 "Display name                                        Service                         Aliases             "
                                                    Line 6 "========================================================================================================"
                                                    #               12345678901234567890123456789012345678901234567890SS123456789012345678901234567890SS12345678901234567890
                                                    #               Windows Media Player Network Sharing Service        TabletInputService              Superfecth
                                                    ForEach($item in $VDITemplate.Optimization.WindowsServices.WindowsServicesList)
                                                    {
                                                            Line 6 ( "{0,-50}  {1,-30}  {2,-20}" -f $item.DisplayName, $item.ServiceName, $item.Aliases)
                                                    }
                                                    Line 0 ""
                                            }
                                            
                                            Line 4 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                            If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                            {
                                                    Line 5 "Windows Scheduled Tasks Optimizations"
                                                    Line 6 "Disable tasks:"
                                                    Line 0 ""
                                                    Line 6 "Task                                                Type    Location                                          "
                                                    Line 6 "=============================================================================================================="
                                                    #               12345678901234567890123456789012345678901234567890SS123456SS12345678901234567890123456789012345678901234567890
                                                    #               MNO Metadata Parser                                 Folder  \Microsoft\Windows\Mobile Broadband Accounts\
                                                    ForEach($item in $VDITemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                                    {
                                                            Line 6 ( "{0,-50}  {1,-6}  {2,-50}" -f $item.Task, $item.Type.ToString(), $item.Location)
                                                    }
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                            If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                            {
                                                    Line 5 "Windows Advanced Options"
                                                    Line 0 ""
                                                    Line 6 "Setting                                           Enabled  Value                                             "
                                                    Line 6 "============================================================================================================="
                                                    #               123456789012345678901234567890123456789012345678SS1234567SS12345678901234567890123456789012345678901234567890
                                                    #               Remove Common program groups from the start menu  False    SomeConfigFile.xml
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable Hibernate", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable Telemetry collection", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable System Restore", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable error reporting to send additional data", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable Tiles", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable Cortana digital assistant", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Turn off Microsoft consumer experience", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Do not show Windows tips", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Remove Common program groups from the Start Menu", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Partial Start Menu layout", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(), `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent)
                                                    
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Network performance: " $OPTNetworkPerformanceEnabled
                                            If($OPTNetworkPerformanceEnabled -eq "True")
                                            {
                                                    Line 5 "Network Performance Optimizations"
                                                    Line 0 ""
                                                    Line 6 "Setting                      Enabled  Value"
                                                    Line 6 "==========================================="
                                                    #               123456789012345678901234567SS1234567SS12345
                                                    #               FileNotFoundCacheEntriesMax  False    32768
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "FileInfoCacheEntriesMax", `
                                                    $VDITemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(), `
                                                    $VDITemplate.Optimization.NetworkPerformance.FileInfoCache)
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "DirectoryCacheEntriesMax", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(), `
                                                    $VDITemplate.Optimization.NetworkPerformance.DirCacheMax)
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "FileNotFoundCacheEntriesMax", `
                                                    $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(), `
                                                    $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCache)
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "DormantFileLimit", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(), `
                                                    $VDITemplate.Optimization.NetworkPerformance.DormantFileLimit)
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "Disable TCP/IP Task Offload", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DisableTCP.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "Disable IPv6 Components", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "Disable IPv6 to IPv4", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "Disables isatap for IPv6", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(), `
                                                    "")
                                                    
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Registry: " $OPTRegistryEnabled
                                            If($OPTRegistryEnabled -eq "True")
                                            {
                                                    Line 5 "Registry Optimizations"
                                                    Line 0 ""
                                                    #               123456789012345678901234567SS1234567SS12345
                                                    #               FileNotFoundCacheEntriesMax  False    32768
                                                    Line 6 "Registry                                  Action  Value                 Type           Data                  Path                                                        "
                                                    Line 6 "========================================================================================================================================================================="
                                                    #               1234567890123456789012345678901234567890SS123456SS12345678901234567890SS1234567890123SS12345678901234567890SS123456789012345678901234567890123456789012345678901234567890
                                                    #               Increase service startup timeouts         Modify  99999999999999999999  REG_EXPAND_SZ  99999999999999999999  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Disk
                                                    ForEach($item in $VDITemplate.Optimization.Registry.RegistryList)
                                                    {
                                                            Line 6 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `
                                                            $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType, $item.DWORDValue, "$($item.HiveType)\$($item.Path)")
                                                    }
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Visual Effects: " $OPTVisualEffectsEnabled
                                            If($OPTVisualEffectsEnabled -eq "True")
                                            {
                                                    Line 5 "Visual Effects Optimizations"
                                                    Line 0 ""
                                                    
                                                    Switch ($VDITemplate.Optimization.VisualEffects.VisualEffectsTypes)
                                                    {
                                                            "LetWindowsChooseWhatsBest"     {$VisualEffectsType = "Let Windows choose what's best"; Break}
                                                            "AdjustForBestAppearnce"        {$VisualEffectsType = "Adjust for best appearance"; Break} #misspelled in the PoSH output and the docs
                                                            "AdjustForBestPerformance"      {$VisualEffectsType = "Adjust for best performance"; Break}
                                                            "Custom"                                        {$VisualEffectsType = "Custom"; Break}
                                                            Default                                         {$VisualEffectsType = "Unable to determine Visual Effects Optimization type: $($VDITemplate.Optimization.VisualEffects.VisualEffectsTypes)"; Break}
                                                    }
                                                    Line 6 $VisualEffectsType
                                                    Line 0 ""
                                                    Line 6 "Setting                                             Enabled"
                                                    Line 6 "==========================================================="
                                                    #               12345678901234567890123456789012345678901234567890SS1234567
                                                    #               Use drop shadows for icon labels on the desktop     False  
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Animate controls and elements inside windows", `
                                                    $VDITemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Animate windows when minimizing and maximizing", `
                                                    $VDITemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Animations in the taskbar", `
                                                    $VDITemplate.Optimization.VisualEffects.AnimateTaskbar.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Enable Peek", `
                                                    $VDITemplate.Optimization.VisualEffects.EnablePeek.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Fade or slide menus into view", `
                                                    $VDITemplate.Optimization.VisualEffects.FadeSlideMenus.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Fade or slide Tooltips into view", `
                                                    $VDITemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Fade out menu items after clicking", `
                                                    $VDITemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Save taskbar thumbnail previews", `
                                                    $VDITemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Show shadows under mouse pointer", `
                                                    $VDITemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Show shadows under windows", `
                                                    $VDITemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Show thumbnails instead of icons", `
                                                    $VDITemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Show translucent selection rectangle", `
                                                    $VDITemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Show window contents while dragging", `
                                                    $VDITemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Slide open combo boxes", `
                                                    $VDITemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Smooth edges of screen fonts", `
                                                    $VDITemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Smooth-scroll list boxes", `
                                                    $VDITemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Use drop shadows for icon labels on the desktop", `
                                                    $VDITemplate.Optimization.VisualEffects.DropShadowsIcon.ToString())
                                                    
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Disk cleanup: " $OPTDiskCleanupEnabled
                                            If($OPTDiskCleanupEnabled -eq "True")
                                            {
                                                    Line 5 "Disk Cleanup Optimizations"
                                                    Line 0 ""
                                                    
                                                    Line 6 "Setting                            Enabled"
                                                    Line 6 "=========================================="
                                                    #               123456789012345678901234567890123SS1234567
                                                    #               Clean up temporary files and logs  False  
                                                    Line 6 ( "{0,-33}  {1,-7}" -f `
                                                    "Clean up redundant system files", `
                                                    $VDITemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString())
                                                    
                                                    Line 6 ( "{0,-33}  {1,-7}" -f `
                                                    "Clean up the WinSxS Folder", `
                                                    $VDITemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString())
                                                    
                                                    Line 6 ( "{0,-33}  {1,-7}" -f `
                                                    "Clean up temporary files and logs", `
                                                    $VDITemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString())
                                                    
                                                    Line 6 ( "{0,-33}  {1,-7}" -f `
                                                    "Remove OneDrive", `
                                                    $VDITemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString())
                                                    
                                                    Line 6 ( "{0,-33}  {1,-7}" -f `
                                                    "Delete users' profiles", `
                                                    $VDITemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString())
                                                    
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Custom script: " $OPTCustomScriptEnabled
                                            If($OPTCustomScriptEnabled  -eq "True")
                                            {
                                                    Line 5 "Custom Script"
                                                    Line 0 ""
                                                    
                                                    Line 6 "Command`t`t : " $VDITemplate.Optimization.CustomScript.Command
                                                    Line 6 "Arguments`t : " $VDITemplate.Optimization.CustomScript.Arguments
                                                    Line 6 "Initial directory: " $VDITemplate.Optimization.CustomScript.InitDir
                                                    Line 6 "Username`t : " $VDITemplate.Optimization.CustomScript.User
                                                    Line 0 ""
                                            }
 
  <>                                         $rowdata = @()
                                            $columnHeaders = @("Inherit default settings:",($Script:htmlsb),$VDITemplate.InheritDefaultOptimizationSettings.ToString(),$htmlwhite)
                                            $rowdata += @(,("Enable optimization:",($Script:htmlsb), $OPTEnableOptimization,$htmlwhite))
                                            $rowdata += @(,("Optimization type:",($Script:htmlsb), $OPTOptimizationType,$htmlwhite))
     
                                            $msg = "Optimization"
                                            $columnWidths = @("300","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
     
                                            WriteHTMLLine 4 0 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                            If($OPTWindowsDefenderATPEnabled -eq "True")
                                            {
                                                    $rowdata = @()
                                                    $columnHeaders = @("Windows Defender ATP Optimizations",($Script:htmlsb),"",$htmlwhite)
     
                                                    If($VDITemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                                    {
                                                            $rowdata += @(,("     Turn off Windows Defender ATP (I use my own ATP solution)",($Script:htmlsb), "",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("     Turn on Windows Defender ATP and set process and folder exclusions",($Script:htmlsb), "",$htmlwhite))
                                                            $rowdata += @(,("     Disable real-time protection",($Script:htmlsb), $VDITemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(),$htmlwhite))
                                                            $rowdata += @(,("",($Script:htmlsb), "",$htmlwhite))
                                                            
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("     Exclude files and folders",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                            }
     
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("     Exclude processes",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                            }
                                                            
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("     Exclude extensions",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                            }
                                                    }
     
     
                                                    $msg = ""
                                                    $columnWidths = @("300","275")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Windows Components: " $OPTWindowsComponentsEnabled
                                            If($OPTWindowsComponentsEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Windows Components Optimizations"
     
                                                    $rowdata = @()
     
                                                    ForEach($item in $VDITemplate.Optimization.WindowsComponents.WindowsComponentsList)
                                                    {
                                                            $rowdata += @(,(
                                                                    $item.DisplayName,$htmlwhite,
                                                                    $item.ComponentName,$htmlwhite)
                                                            )
                                                    }
     
                                        $columnHeaders = @(                                                   $columnHeaders = @(
                                                            "Display Name",($Script:htmlsb),
                                                            "Component",($Script:htmlsb)
                                                    )
     
                                                    $msg = "Disable (remove) components:"
                                                    $columnWidths = @("200","200")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                            If($OPTWindowsServicesEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Windows Services Optimizations"
     
                                                    $rowdata = @()
     
                                                    ForEach($item in $VDITemplate.Optimization.WindowsServices.WindowsServicesList)
                                                    {
                                                            $rowdata += @(,(
                                                                    $item.DisplayName,$htmlwhite,
                                                                    $item.ServiceName,$htmlwhite,
                                                                    $item.Aliases,$htmlwhite)
                                                            )
                                                    }
     
                                                    $columnHeaders = @(
                                                            "Display Name",($Script:htmlsb),
                                                            "Service",($Script:htmlsb),
                                                            "Aliases",($Script:htmlsb)
                                                    )
     
                                                    $msg = "Disable services:"
                                                    $columnWidths = @("200","100","50")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled
                                            If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Windows Scheduled Tasks Optimizations"
     
                                                    $rowdata = @()
     
                                                    ForEach($item in $VDITemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                                    {
                                                            $rowdata += @(,(
                                                                    $item.Task,$htmlwhite,
                                                                    $item.Type.Tostring(),$htmlwhite,
                                                                    $item.Location,$htmlwhite)
                                                            )
                                                    }
     
                                                    $columnHeaders = @(
                                                            "Task",($Script:htmlsb),
                                                            "Type",($Script:htmlsb),
                                                            "Location",($Script:htmlsb)
                                                    )
     
                                                    $msg = "Disable tasks:"
                                                    $columnWidths = @("200","50","250")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                            If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Windows Advanced Options"
     
                                                    $rowdata = @()
     
                                                    $rowdata += @(,(
                                                            "Disable Hibernate",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable Telemetry collection",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable System Restore",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable error reporting to send additional data",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable Tiles",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable Cortana digital assistant",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Turn off Microsoft consumer experience",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Do not show Windows tips",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Remove Common program groups from the Start Menu",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Partial Start Menu layout",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(),$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent,$htmlwhite)
                                                    )
     
                                                    $columnHeaders = @(
                                                            "Setting",($Script:htmlsb),
                                                            "Enabled",($Script:htmlsb),
                                                            "Value",($Script:htmlsb)
                                                    )
     
                                                    $msg = ""
                                                    $columnWidths = @("300","50","200")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                            If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Network Performance Optimizations"
     
                                                    $rowdata = @()
     
                                                    $rowdata += @(,(
                                                            "FileInfoCacheEntriesMax",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(),$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.FileInfoCache,$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "DirectoryCacheEntriesMax",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(),$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DirCacheMax,$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "FileNotFoundCacheEntriesMax",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(),$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCache,$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "DormantFileLimit",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(),$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DormantFileLimit,$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable TCP/IP Task Offload",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DisableTCP.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable IPv6 Components",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable IPv6 to IPv4",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disables isatap for IPv6",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $columnHeaders = @(
                                                            "Setting",($Script:htmlsb),
                                                            "Enabled",($Script:htmlsb),
                                                            "Value",($Script:htmlsb)
                                                    )
     
                                                    $msg = ""
                                                    $columnWidths = @("170","50","50")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Registry: " $OPTRegistryEnabled       
                                            If($OPTRegistryEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Registry Optimizations"
     
                                                    $rowdata = @()
     
                                                    ForEach($item in $VDITemplate.Optimization.Registry.RegistryList)
                                                    {
                                                            $rowdata += @(,(
                                                                    $item.DisplayName,$htmlwhite,
                                                                    $item.Action,$htmlwhite,
                                                                    $item.RegistryName,$htmlwhite,
                                                                    $item.RegType,$htmlwhite,
                                                                    $item.DWORDValue,$htmlwhite,
                                                                    "$($item.HiveType)\$($item.Path)",$htmlwhite)
                                                            )
                                                    }
     
                                                    $columnHeaders = @(
                                                            "Registry",($Script:htmlsb),
                                                            "Action",($Script:htmlsb),
                                                            "Value",($Script:htmlsb),
                                                            "Type",($Script:htmlsb),
                                        "Gateways",($Script:htmlsb),                                                           "Data",($Script:htmlsb),
                                        "Status",($Script:htmlsb))                                                           "Path",($Script:htmlsb)
                                                    )
 
                                        $msg = "" <>                                                 $msg = ""
                                                    $columnWidths = @("200","50","100","100","100","200")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                            If($OPTVisualEffectsEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Visual Effects Optimizations"
     
                                                    $rowdata = @()
     
                                                    $rowdata += @(,(
                                                            "Animate controls and elements inside windows",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Animate windows when minimizing and maximizing",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Animations in the taskbar",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.AnimateTaskbar.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Enable Peek",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.EnablePeek.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Fade or slide menus into view",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.FadeSlideMenus.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Fade or slide Tooltips into view",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Fade out menu items after clicking",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Save taskbar thumbnail previews",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Show shadows under mouse pointer",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Show shadows under windows",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Show thumbnails instead of icons",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Show translucent selection rectangle",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Show window contents while dragging",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Slide open combo boxes",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Smooth edges of screen fonts",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Smooth-scroll list boxes",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Use drop shadows for icon labels on the desktop",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.DropShadowsIcon.ToString(),$htmlwhite)
                                                    )
     
                                                    $columnHeaders = @(
                                                            "Setting",($Script:htmlsb),
                                                            "Enabled",($Script:htmlsb)
                                                    )
     
                                                    $msg = ""
                                                    $columnWidths = @("275","50")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                            If($OPTDiskCleanupEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Disk Cleanup Optimizations"
     
                                                    $rowdata = @()
     
                                                    $rowdata += @(,(
                                                            "Clean up redundant system files",$htmlwhite,
                                                            $VDITemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Clean up the WinSxS Folder",$htmlwhite,
                                                            $VDITemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Clean up temporary files and logs",$htmlwhite,
                                                            $VDITemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Remove OneDrive",$htmlwhite,
                                                            $VDITemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Delete users' profiles",$htmlwhite,
                                                            $VDITemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString(),$htmlwhite)
                                                    )
     
                                                    $columnHeaders = @(
                                                            "Setting",($Script:htmlsb),
                                                            "Enabled",($Script:htmlsb)
                                                    )
     
                                                    $msg = ""
                                        $columnWidths = @("200","400")                                                   $columnWidths = @("200","50")
                                        FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"                                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        WriteHTMLLine 0 0 ""                                                   WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Custom script: " $OPTCustomScriptEnabled
                                            If($OPTCustomScriptEnabled -eq "True")
                                            {
                                                    $rowdata = @()
                                                    $columnHeaders = @("Custom Script",($Script:htmlsb),"",$htmlwhite)
                                                    $rowdata += @(,("     Command",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.Command,$htmlwhite))
                                                    $rowdata += @(,("     Arguments",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.Arguments,$htmlwhite))
                                                    $rowdata += @(,("     Initial directory",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.InitDir,$htmlwhite))
                                                    $rowdata += @(,("     Username",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.User,$htmlwhite))
     
                                                    $msg = ""
                                                    $columnWidths = @("125","200")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
 
<# <>  
                                    #License Keys
                                    
 
                                        WriteWordLine 4 0 "Device Manager" <>                                         WriteWordLine 4 0 "License Keys"
 
                                        Line 2 "Device Manager" <>                                         Line 3 "License Keys"
 
                                        $ScriptInformation.Add(@{Data = "Port"; Value = ""; }) > $Null +-  
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Port: "    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Port",($Script:htmlsb),"",$htmlwhite)    
                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))    
     
                                        $msg = "Device Manager"    
                                        $columnWidths = @("200","400")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
#>    
     
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "Devices"    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Devices"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                $HALBDevices = Get-RASHALBDevice -HALBName $HALB.Name -EA 0 4> $Null    
                                    
                                If((!$?) -or ($? -and $Null -eq $HALBDevices))    
                                {    
                                        Write-Host "    
                                        No HALB Devices retrieved for HALB $($HALB.Name).`    
                                        " -ForegroundColor White    
                                        If($MSWord -or $PDF)    
                                        {    
                                                WriteWordLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"    
                                        }    
                                        If($Text)    
                                        {    
                                                Line 0 "No HALB Devices retrieved for HALB $($HALB.Name)"    
                                        }    
                                        If($HTML)    
                                        {    
                                                WriteHTMLLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"    
                                        }    
                                }    
                                Else    
                                {    
                                        If($MSWord -or $PDF)    
                                        {    
                                                [System.Collections.Hashtable[]] $HALBDevicesWordTable = @();    
                                        }    
                                        If($Text)    
                                        {    
                                                Line 3 "Devices          ID"    
                                                Line 3 "==================="    
                                                #       999.999.999.999SS12    
                                        }    
                                        If($HTML)    
                                        {    
                                                $rowdata = @()    
                                        }    
 
                                        #process the gateways data <>                                         If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")
                                        ForEach($HALBDevice in $HALBDevices)    
 
                                                $ip = $HALBDevice.DeviceIP <>  
                                                $ID = $HALBDevice.DeviceId    
                                                    
                                                If($MSWord -or $PDF)    
                                                {    
                                                        $HALBDevicesWordTableRowHash = @{    
                                                                DeviceIP = $ip;    
                                                                DeviceID = $ID;    
                                                        }    
                                                        $HALBDevicesWordTable += $HALBDevicesWordTableRowHash    
                                                }    
                                                If($Text)    
                                                {    
                                                        Line 3 ( "{0,-15}  {1,-2}" -f $ip, $ID)    
                                                }    
                                                If($HTML)    
                                                {    
                                                        $rowdata += @(,(    
                                                        $ip,$htmlwhite,    
                                                        $ID,$htmlwhite))    
                                                }    
                                        }    
                                            
                                        #output the Word/PDF and HTML tables    
                                        If($MSWord -or $PDF)    
                                        {    
                                                If($HALBDevicesWordTable.Count -gt 0)    
                                                {    
                                                        $Table = AddWordTable -Hashtable $HALBDevicesWordTable `    
                                                        -Columns  DeviceIP,DeviceID `    
                                                        -Headers  "Devices","ID" `    
                                                        -Format $wdTableGrid `    
                                                        -AutoFit $wdAutoFitFixed;    
     
                                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                        $Table.Columns.Item(1).Width = 100;    
                                                        $Table.Columns.Item(2).Width = 50;    
     
                                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                        FindWordDocumentEnd    
                                                        $Table = $Null    
                                                        WriteWordLine 0 0 ""    
                                                }    
                                        }    
                                        If($Text)    
                                        {    
                                                Line 0 ""    
                                        }    
                                        If($HTML)    
                                        {    
                                                $columnHeaders = @(    
                                                "Devices",($Script:htmlsb),    
                                                "ID",($Script:htmlsb))    
     
                                                $msg = ""    
                                                $columnWidths = @("100","50")    
                                                FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "150"    
                                                WriteHTMLLine 0 0 ""    
                                        }    
                                }    
     
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "Advanced"    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Advanced"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Enable RDP UPD tunneling"; Value = $HALB.EnableUDPTunneling.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Maximum TCP connections"; Value = $HALB.MaxTCPConnections.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Client inactivity timeout (s)"; Value = $HALB.ClientIdleTimeout.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Gateway connection timeout (s)"; Value = $HALB.GWConnectionTimeout.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Client connection queue timeout (s)"; Value = $HALB.ClientQueueTimeout.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Gateway inactivity timeout (s)"; Value = $HALB.GatewayIdleTimeout.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Amount of TCP connections per second"; Value = $HALB.SessionsRate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Gateways health check intervals (s)"; Value = $HALB.GWHealthCheckInterval.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP virtual router ID"; Value = $HALB.VirtualRouterID.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP authentication password"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP broadcast interval (m)"; Value = $HALB.VrrpBroadcastInterval.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP health check script interval (s)"; Value = $HALB.VrrpHealthCheckInterval.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP health check script timeout"; Value = $HALB.VrrpHealthCheckTimeout.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP advertisement interval (s)"; Value = $HALB.VrrpAdvertInterval.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Enable OS updates"; Value = $HALB.OSUpdate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Keep existing load balancing settings"; Value = $HALB.KeepLBProxyConfig.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Keep existing VRRP/keepalive settings"; Value = $HALB.KeepVRRPConfig.ToString(); }) > $Null                                                   $ScriptInformation.Add(@{Data = "License key management type"; Value = "Key Management Service (KMS)"; }) > $Null
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }                                           }
                                If($Text)    
                                {    
                                        Line 3 "Enable RDP UPD tunneling`t`t: " $HALB.EnableUDPTunneling.ToString()    
                                        Line 3 "Maximum TCP connections`t`t`t: " $HALB.MaxTCPConnections.ToString()    
                                        Line 3 "Client inactivity timeout (s)`t`t: " $HALB.ClientIdleTimeout.ToString()    
                                        Line 3 "Gateway connection timeout (s)`t`t: " $HALB.GWConnectionTimeout.ToString()    
                                        Line 3 "Client connection queue timeout (s)`t: " $HALB.ClientQueueTimeout.ToString()    
                                        Line 3 "Gateway inactivity timeout (s)`t`t: " $HALB.GatewayIdleTimeout.ToString()    
                                        Line 3 "Amount of TCP connections per second`t: " $HALB.SessionsRate.ToString()    
                                        Line 3 "Gateways health check intervals (s)`t: " $HALB.GWHealthCheckInterval.ToString()    
                                        Line 3 "VRRP virtual router ID`t`t`t: " $HALB.VirtualRouterID.ToString()    
                                        Line 3 "VRRP authentication password`t`t: "     
                                        Line 3 "VRRP broadcast interval (m)`t`t: " $HALB.VrrpBroadcastInterval.ToString()    
                                        Line 3 "VRRP health check script interval (s)`t: " $HALB.VrrpHealthCheckInterval.ToString()    
                                        Line 3 "VRRP health check script timeout`t: " $HALB.VrrpHealthCheckTimeout.ToString()    
                                        Line 3 "VRRP advertisement interval (s)`t`t: " $HALB.VrrpAdvertInterval.ToString()    
                                        Line 3 "Enable OS updates`t`t`t: " $HALB.OSUpdate.ToString()    
                                        Line 3 "Keep existing load balancing settings`t: " $HALB.KeepLBProxyConfig.ToString()    
                                        Line 3 "Keep existing VRRP/keepalive settings`t: " $HALB.KeepVRRPConfig.ToString()    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Enable RDP UPD tunneling",($Script:htmlsb),$HALB.EnableUDPTunneling.ToString(),$htmlwhite)    
                                        $rowdata += @(,("Maximum TCP connections",($Script:htmlsb),$HALB.MaxTCPConnections.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Client inactivity timeout (s)",($Script:htmlsb),$HALB.ClientIdleTimeout.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Gateway connection timeout (s)",($Script:htmlsb),$HALB.GWConnectionTimeout.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Client connection queue timeout (s)",($Script:htmlsb),$HALB.ClientQueueTimeout.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Gateway inactivity timeout (s)",($Script:htmlsb),$HALB.GatewayIdleTimeout.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Amount of TCP connections per second",($Script:htmlsb),$HALB.SessionsRate.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Gateways health check intervals (s)",($Script:htmlsb),$HALB.GWHealthCheckInterval.ToString(),$htmlwhite))    
                                        $rowdata += @(,("VRRP virtual router ID",($Script:htmlsb),$HALB.VirtualRouterID.ToString(),$htmlwhite))    
                                        $rowdata += @(,("VRRP authentication password",($Script:htmlsb),"",$htmlwhite))    
                                        $rowdata += @(,("VRRP broadcast interval (m)",($Script:htmlsb),$HALB.VrrpBroadcastInterval.ToString(),$htmlwhite))    
                                        $rowdata += @(,("VRRP health check script interval (s)",($Script:htmlsb),$HALB.VrrpHealthCheckInterval.ToString(),$htmlwhite))    
                                        $rowdata += @(,("VRRP health check script timeout",($Script:htmlsb),$HALB.VrrpHealthCheckTimeout.ToString(),$htmlwhite))    
                                        $rowdata += @(,("VRRP advertisement interval (s)",($Script:htmlsb),$HALB.VrrpAdvertInterval.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Enable OS updates",($Script:htmlsb),$HALB.OSUpdate.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Keep existing load balancing settings",($Script:htmlsb),$HALB.KeepLBProxyConfig.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Keep existing VRRP/keepalive settings",($Script:htmlsb),$HALB.KeepVRRPConfig.ToString(),$htmlwhite))    
     
                                        $msg = "Advanced"    
                                        $columnWidths = @("200","400")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
                }    
        }    
            
        #Themes    
        $Themes = Get-RASTheme -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Themes for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Themes for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Themes for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Themes for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $Themes)    
        {    
                Write-Host "    
                No Themes retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Themes retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No Themes retrieved for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Themes retrieved for Site $($Site.Name)"    
                }    
        }    
        Else                                           Else
        {                                           {
                If($MSWord -or $PDF)                                                   $ScriptInformation.Add(@{Data = "License key management type"; Value = "Multple Activation Key (MAK)"; }) > $Null
                {    
                        WriteWordLine 2 0 "Themes"    
                }    
                If($Text)    
                {    
                        Line 1 "Themes"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 "Themes"    
                }    
     
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Themes"    
                ForEach($Theme in $Themes)    
                {    
                        $ThemePostLogonMessage        = $Theme.PostLogonMessage.Split("`n")    
                        $ThemeHTML5PrelogonMessage    = $Theme.HTML5Client.Message.PreLogonMessage.Split("`n")    
                        $ThemeHTML5PostlogonMessage   = $Theme.HTML5Client.Message.HTML5PostLogonMessage.Split("`n")    
                        $ThemeWindowsPostlogonMessage = $Theme.WindowsClient.Messages.WindowsClientPostLogonMessage.Split("`n")    
                        $ThemeHTML5URL                = "https://FQDN/$($Theme.HTML5Client.Url.LoginPageURLPath)"    
                        $ThemeShowDownloadURL         = $Theme.HTML5Client.Url.ShowDownloadURL.ToString()    
                        $ThemeOverrideDownloadURL     = $Theme.HTML5Client.Url.OverrideWindowsClientDownloadURL    
                        $ThemeFooterURLs              = @(Get-RASThemeFooterURL -Name $Theme.Name -EA 0) 4> $Null #fixed in 2.52 thanks to Thomas Krampe    
                                                                          
                        If(!$? -or $Null -eq $ThemeFooterURLs)    
                        {    
                                $ThemeFooterURLs = @()    
                        }    
                            
                        #the Get-RASThemeImage cmdlet returns all four items as an array, but there is nothing that    
                        #specifies which array element is which branding image file    
                        #I get each image file separately to make sure each image file is correctly associated    
                        $ThemeCompanyLogo = Get-RASThemeImage -Name $Theme.name -ImageType CompanyLogo -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                $ThemeCompanyLogo = ""    
                        }    
                            
                            
                        $ThemeFaviconIcon = Get-RASThemeImage -Name $Theme.name -ImageType FaviconIcon -EA 0 4>$Null                                                   $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null
                                                                          
                        If(!$?)    
                        {    
                                $ThemeFaviconIcon = ""                                                   ForEach($Item in $LicenseKeys)
                        }    
     
                            
                        $ThemeConnectionBanner = Get-RASThemeImage -Name $Theme.name -ImageType ConnectionBanner -EA 0 4>$Null    
                            
                        If(!$?)    
                        {                                                   {
                                $ThemeConnectionBanner = ""    
                        }    
     
                            
                        $ThemeApplicationIcon = Get-RASThemeImage -Name $Theme.name -ImageType ApplicationIcon -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                $ThemeApplicationIcon = ""    
                        }    
                            
                        $ThemeHTML5LaunchSessionsUsing = ""    
                        Switch($Theme.HTML5Client.Gateway.LaunchMethod)    
                        {    
                                "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"      
                                {    
                                        $ThemeHTML5LaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break    
                                }    
                                "Launch_Applications_with_Parallels_Client"                                                 
                                {    
                                        $ThemeHTML5LaunchSessionsUsing = "Launch apps with Parallels Client"; Break    
                                }    
                                "Launch_Applications_with_Browser_HTML5"                                                    
                                {    
                                        $ThemeHTML5LaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break    
                                }    
                                Default                                                                                                                     
                                {    
                                        $ThemeHTML5LaunchSessionsUsing = "Unable to determine Launch sessions using: $($Theme.HTML5Client.Gateway.LaunchMethod)"; Break    
                                }    
                        }    
                            
                        $ThemeHTMLFileTransfer = ""    
                        Switch($Theme.HTML5Client.Gateway.FileTransferMode)    
                        {    
                                "Disabled"                      {$ThemeHTMLFileTransfer = "Disabled"; Break}    
                                "ClientToServer"        {$ThemeHTMLFileTransfer = "Client to server only"; Break}    
                                "ServerToClient"        {$ThemeHTMLFileTransfer = "Server to client only"; Break}    
                                "Bidirectional"         {$ThemeHTMLFileTransfer = "Bidirectional"; Break}    
                                Default                         {$ThemeHTMLFileTransfer = "Unable to determine File transfer mode: $($Theme.HTML5Client.Gateway.FileTransferMode)"; Break}    
                        }    
                            
                        $ThemeHTMLClipboardDirection = ""    
                        Switch($Theme.HTML5Client.Gateway.ClipboardDirection)    
                        {    
                                "None"                          {$ThemeHTMLClipboardDirection = "None"; Break}    
                                "ClientToServer"        {$ThemeHTMLClipboardDirection = "Client to server only"; Break}    
                                "ServerToClient"        {$ThemeHTMLClipboardDirection = "Server to client only"; Break}    
                                "Bidirectional"         {$ThemeHTMLClipboardDirection = "Bidirectional"; Break}    
                                Default                         {$ThemeHTMLClipboardDirection = "Unable to determine Clipboard direction: $($Theme.HTML5Client.Gateway.ClipboardDirection)"; Break}    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 3 0 "Theme $($Theme.Name)"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $Theme.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $Theme.Description; }) > $Null                                                           $ScriptInformation.Add(@{Data = "License Key"; Value = $Item.LicenseKey; }) > $Null
                                $ScriptInformation.Add(@{Data = "HTML5 URL"; Value = $ThemeHTML5URL; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Theme.AdminLastMod; }) > $Null                                                           $ScriptInformation.Add(@{Data = "Key Limit"; Value = $Item.KeyLimit; }) > $Null
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $Theme.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $Theme.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $Theme.TimeCreate.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "ID"; Value = $Theme.Id.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Theme $($Theme.Name)"    
                                Line 3 "Name`t`t`t: " $Theme.Name    
                                Line 3 "Description`t`t: " $Theme.Description    
                                Line 3 "HTML5 URL`t`t: " $ThemeHTML5URL    
                                Line 3 "Last modification by`t: " $Theme.AdminLastMod    
                                Line 3 "Modified on`t`t: " $Theme.TimeLastMod.ToString()    
                                Line 3 "Created by`t`t: " $Theme.AdminCreate    
                                Line 3 "Created on`t`t: " $Theme.TimeCreate.ToString()    
                                Line 3 "ID`t`t`t: " $Theme.Id.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $ThemeName = $Theme.Name.Replace("<","").Replace(">","")    
                                WriteHTMLLine 3 0 "Theme $ThemeName"    
                                $rowdata = @()    
                                $columnHeaders = @("Name",($Script:htmlsb),$ThemeName,$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$Theme.Description,$htmlwhite))    
                                $rowdata += @(,("HTML5 URL",($Script:htmlsb),$ThemeHTML5URL,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $Theme.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb), $Theme.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb), $Theme.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb), $Theme.TimeCreate.ToString(),$htmlwhite))    
                                $rowdata += @(,("ID",($Script:htmlsb),$Theme.Id.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "General"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "General"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Enable Theme"; Value = $Theme.Enabled.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $Theme.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $Theme.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Override authentication domain"; Value = $Theme.OverrideAuthenticationDomain.ToString(); }) > $Null    
                                If($Theme.OverrideAuthenticationDomain)    
                                {    
                                        $ScriptInformation.Add(@{Data = "     Domain"; Value = $Theme.Domain; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "Limit access to this theme to members of these AD groups"; Value = $Theme.GroupEnabled.ToString(); }) > $Null    
                                If($Theme.GroupEnabled)    
                                {    
                                        ForEach($Group in $Theme.GroupFilters)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Group: $($Group.name) SID: $($Group.sid)"; }) > $Null    
                                        }                                                   }
                                }                                           }
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Enable Theme`t`t`t: " $Theme.Enabled.ToString()                                           If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")
                                Line 3 "Name`t`t`t`t: " $Theme.Name    
                                Line 3 "Description`t`t`t: " $Theme.Description    
                                Line 3 "Override authentication domain`t: " $Theme.OverrideAuthenticationDomain.ToString()    
                                If($Theme.OverrideAuthenticationDomain)    
                                {                                           {
                                        Line 6 "Domain  : " $Theme.Domain                                                   Line 4 "License key management type: " "Key Management Service (KMS)"
                                }                                           }
                                Line 3 "Limit access to this theme to "                                           Else
                                Line 3 "members of these AD groups`t: " $Theme.GroupEnabled.ToString()    
                                If($Theme.GroupEnabled)    
                                {                                           {
                                                    Line 4 "License key management type: " "Multple Activation Key (MAK)"
                                                    
                                                    $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null
     
                                        ForEach($Group in $Theme.GroupFilters)                                                   ForEach($Item in $LicenseKeys)
                                        {                                                   {
                                                Line 7 "  Group: $($Group.name) SID: $($Group.sid)"                                                           Line 4 "License Key`t: " $Item.LicenseKey
                                                            Line 4 "Key Limit`t: " $Item.KeyLimit
                                        }                                                   }
                                }                                           }
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $ThemeName = $Theme.Name.Replace("<","").Replace(">","")    
                                $rowdata = @()                                           $rowdata = @()
                                            If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")
                                            {
                                $columnHeaders = @("Enable Theme",($Script:htmlsb),$Theme.Enabled.ToString(),$htmlwhite)                                                   $columnHeaders = @("License key management type",($Script:htmlsb),"Key Management Service (KMS)",$htmlwhite)
                                            }
                                            Else
                                            {
                                $rowdata += @(,("Name",($Script:htmlsb),$ThemeName,$htmlwhite))                                                   $columnHeaders = @("License key management type",($Script:htmlsb),"Multple Activation Key (MAK)",$htmlwhite)
                                                    
                                                    $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null
     
                                                    $cnt = -1
                                                    ForEach($Item in $LicenseKeys)
                                                    {
                                $rowdata += @(,("Description",($Script:htmlsb),$Theme.Description,$htmlwhite))                                                           $rowdata += @(,("License Key",($Script:htmlsb),$Item.LicenseKey,$htmlwhite))
                                $rowdata += @(,("Override authentication domain",($Script:htmlsb),$Theme.OverrideAuthenticationDomain.ToString(),$htmlwhite))                                                           $rowdata += @(,("Key Limit",($Script:htmlsb),$Item.KeyLimit,$htmlwhite))
                                                    }
                                            }
     
                                            $msg = "License Keys"
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
                                    
                                    #Settings
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 4 0 "Settings"
                                    }
                                    If($Text)
                                    {
                                            Line 3 "Settings"
                                    }
                                    If($HTML)
                                    {
                                            #Nothing
                                    }
                                    
                                If($Theme.OverrideAuthenticationDomain)                                   If($VDITemplate.InheritDefaultVDIActionSettings)
 
                                        $rowdata += @(,("     Domain",($Script:htmlsb),$Theme.Domain,$htmlwhite)) <>                                         #do we inherit site defaults?
                                            #yes we do, get the default settings for the Site
                                            #use the Site default settings
     
                                            $VDIDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                            
                                            If($? -and $Null -ne $VDIDefaults)
                                            {
                                                    Switch ($VDIDefaults.SessionResetTimeoutSec)
                                                    {
                                                            0               {$VDITemplateLogoffActiveSessionAfter = "Never"; Break}
                                                            1               {$VDITemplateLogoffActiveSessionAfter = "Immediate"; Break}
                                                            25              {$VDITemplateLogoffActiveSessionAfter = "25 seconds"; Break}
                                                            60              {$VDITemplateLogoffActiveSessionAfter = "1 minute"; Break}
                                                            300             {$VDITemplateLogoffActiveSessionAfter = "5 minutes"; Break}
                                                            3600    {$VDITemplateLogoffActiveSessionAfter = "1 hour"; Break}
                                                            7200    {$VDITemplateLogoffActiveSessionAfter = "2 hours"; Break}
                                                            Default {$VDITemplateLogoffActiveSessionAfter = "Unable to determine Logoff active session after: $($VDIDefaults.SessionResetTimeoutSec)"; Break}
                                                    }
                                                    
                                                    Switch ($VDIDefaults.PerformActionAfterSec)
                                                    {
                                                            0               {$VDITemplateActionsAfter = "Never"; Break}
                                                            1               {$VDITemplateActionsAfter = "Immediate"; Break}
                                                            25              {$VDITemplateActionsAfter = "25 seconds"; Break}
                                                            60              {$VDITemplateActionsAfter = "1 minute"; Break}
                                                            300             {$VDITemplateActionsAfter = "5 minutes"; Break}
                                                            3600    {$VDITemplateActionsAfter = "1 hour"; Break}
                                                            7200    {$VDITemplateActionsAfter = "2 hours"; Break}
                                                            Default {$VDITemplateActionsAfter = "Unable to determine Actions After: $($VDIDefaults.PerformActionAfterSec)"; Break}
                                                    }
                                                    $VDITemplateActionsOnSession         = $VDIDefaults.SessionAction.ToString()
                                                    $VDITemplateActionsPerformAction     = $VDIDefaults.PerformAction.ToString()
                                            }
                                            Else
                                            {
                                                    #unable to retrieve default, use built-in default values
                                                    $VDITemplateLogoffActiveSessionAfter = "Never"
                                                    $VDITemplateActionsOnSession         = "Disconnect"
                                                    $VDITemplateActionsPerformAction     = "Do nothing"
                                                    $VDITemplateActionsAfter             = "Never"
                                            }
 
  <>                                 Else
                                    {
                                            #No, we don't use the VDI Template settings
                                            Switch ($VDITemplate.SessionResetTimeoutSec)
                                            {
                                                    0               {$VDITemplateLogoffActiveSessionAfter = "Never"; Break}
                                                    1               {$VDITemplateLogoffActiveSessionAfter = "Immediate"; Break}
                                                    25              {$VDITemplateLogoffActiveSessionAfter = "25 seconds"; Break}
                                                    60              {$VDITemplateLogoffActiveSessionAfter = "1 minute"; Break}
                                                    300             {$VDITemplateLogoffActiveSessionAfter = "5 minutes"; Break}
                                                    3600    {$VDITemplateLogoffActiveSessionAfter = "1 hour"; Break}
                                                    7200    {$VDITemplateLogoffActiveSessionAfter = "2 hours"; Break}
                                $rowdata += @(,("Limit access to this theme to members of these AD groups",($Script:htmlsb),$Theme.GroupEnabled.ToString(),$htmlwhite))                                                   Default {$VDITemplateLogoffActiveSessionAfter = "Unable to determine Logoff active session after: $($VDITemplate.SessionResetTimeoutSec)"; Break}
                                If($Theme.GroupEnabled)                                           }
                                            
                                            Switch ($VDITemplate.PerformActionAfterSec)
                                {                                           {
                                        ForEach($Group in $Theme.GroupFilters)                                                   0               {$VDITemplateActionsAfter = "Never"; Break}
                                                    1               {$VDITemplateActionsAfter = "Immediate"; Break}
                                                    25              {$VDITemplateActionsAfter = "25 seconds"; Break}
                                                    60              {$VDITemplateActionsAfter = "1 minute"; Break}
                                                    300             {$VDITemplateActionsAfter = "5 minutes"; Break}
                                                    3600    {$VDITemplateActionsAfter = "1 hour"; Break}
                                                    7200    {$VDITemplateActionsAfter = "2 hours"; Break}
                                                    Default {$VDITemplateActionsAfter = "Unable to determine Actions After: $($VDITemplate.PerformActionAfterSec)"; Break}
                                            }
                                            $VDITemplateActionsOnSession         = $VDITemplate.SessionAction.ToString()
                                            $VDITemplateActionsPerformAction     = $VDITemplate.PerformAction.ToString()
                                    }
                                    
                                    If($MSWord -or $PDF)
                                        {                                   {
                                                $rowdata += @(,("",($Script:htmlsb),"Group: $($Group.name) SID: $($Group.sid)",$htmlwhite))                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultVDIActionSettings.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Application session lingering"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Logoff active session after"; Value = $VDITemplateLogoffActiveSessionAfter; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Actions"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     On session"; Value = $VDITemplateActionsOnSession; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Perform action"; Value = $VDITemplateActionsPerformAction; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     After"; Value = $VDITemplateActionsAfter; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                        }                                   }
                                    If($Text)
                                    {
                                            Line 4 "Inherit default settings`t`t: " $VDITemplate.InheritDefaultVDIActionSettings.ToString()
                                            Line 4 "Application session lingering"
                                            Line 5 "Logoff active session after`t: " $VDITemplateLogoffActiveSessionAfter
                                            Line 4 "Actions"
                                            Line 5 "On session`t`t`t: " $VDITemplateActionsOnSession
                                            Line 5 "Perform action`t`t`t: " $VDITemplateActionsPerformAction
                                            Line 5 "After`t`t`t`t: " $VDITemplateActionsAfter
                                            Line 0 ""
 
  -+                                 If($HTML)
                                    {
 
  <>                                         $rowdata = @()
                                            $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefaultVDIActionSettings.ToString(),$htmlwhite)
                                            $rowdata += @(,("Application session lingering",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,( "     Logoff active session after",($Script:htmlsb),$VDITemplateLogoffActiveSessionAfter,$htmlwhite))
                                            $rowdata += @(,( "Actions",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,( "     On session",($Script:htmlsb),$VDITemplateActionsOnSession,$htmlwhite))
                                            $rowdata += @(,( "     Perform action",($Script:htmlsb),$VDITemplateActionsPerformAction,$htmlwhite))
                                            $rowdata += @(,( "     After",($Script:htmlsb),$VDITemplateActionsAfter,$htmlwhite))
     
                                $msg = "General"                                           $msg = "Settings"
                                $columnWidths = @("200","400")                                           $columnWidths = @("200","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
     
                                    #Security
                                                          
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 4 0 "Messages"                                           WriteWordLine 4 0 "Security"
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 2 "Messages"                                           Line 3 "Security"
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                #Nothing                                           #Nothing
                                    }
                                    
                                    If($VDITemplate.InheritDefaultVDISecuritySettings)
                                    {
                                            #do we inherit site defaults?
                                            #yes we do, get the default settings for the Site
                                            #use the Site default settings
     
                                            $VDIDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                            
                                            If($? -and $Null -ne $VDIDefaults)
                                            {
                                                    $VDITemplateGrantPermissions  = $VDIDefaults.IsUsersGrantedRDPermissions.ToString()
                                                    If($VDIDefaults.GroupType -eq "Administrators")
                                                    {
                                                            $VDITemplateSecurityGroup = "Administrators"
                                                    }
                                                    Else
                                                    {
                                                            $VDITemplateSecurityGroup = "Remote Desktop Users group"
                                                    }
                                            }
                                            Else
                                            {
                                                    #unable to retrieve default, use built-in default values
                                                    $VDITemplateGrantPermissions = "False"
                                                    $VDITemplateSecurityGroup    = ""
                                            }
                                    }
                                    Else
                                    {
                                            #No, we don't use the VDI Template settings
                                            $VDITemplateGrantPermissions  = $VDITemplate.IsUsersGrantedRDPermissions.ToString()
                                            If($VDITemplate.GroupType -eq "Administrators")
                                            {
                                                    $VDITemplateSecurityGroup = "Administrators"
                                            }
                                            Else
                                            {
                                                    $VDITemplateSecurityGroup = "Remote Desktop Users group"
                                            }
                                    }
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultVDISecuritySettings.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Grant users Remote Desktop connection permissions"; Value = $VDITemplateGrantPermissions; }) > $Null
                                            If($VDITemplateGrantPermissions -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Local security group"; Value = $VDITemplateSecurityGroup; }) > $Null
                                            }
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    If($Text)
                                    {
                                            Line 4 "Inherit default settings`t`t`t : " $VDITemplate.InheritDefaultVDISecuritySettings.ToString()
                                            Line 4 "Grant users Remote Desktop connection permissions: " $VDITemplateGrantPermissions
                                            If($VDITemplateGrantPermissions -eq "True")
                                            {
                                                    Line 5 "Local security group`t`t`t : " $VDITemplateSecurityGroup
                                            }
                                            Line 0 ""
                                    }
                                    If($HTML)
                                    {
     
                                            $rowdata = @()
                                            $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefaultVDISecuritySettings.ToString(),$htmlwhite)
                                            $rowdata += @(,( "Grant users Remote Desktop connection permissions",($Script:htmlsb),$VDITemplateGrantPermissions,$htmlwhite))
                                            If($VDITemplateGrantPermissions -eq "True")
                                            {
                                                    $rowdata += @(,( "Local security group",($Script:htmlsb),$VDITemplateSecurityGroup,$htmlwhite))
                                            }
     
                                            $msg = "Security"
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
 
  -+  
                    }
                    
                    #Desktops
                    #can't find this
            }
            
            #Providers
            $Providers = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Providers for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Providers for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $Providers)
            {
                    Write-Host "
                    No Providers retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Providers retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Providers retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Providers retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "Providers"
                    }
                    If($Text)
                    {
                            Line 1 "Providers"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "Providers"
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Providers"
                    ForEach($Provider in $Providers)
                    {
                            $ProviderStatus = Get-RASProviderStatus -Id $Provider.Id -EA 0 4>$Null
 
  <>                         If(!$?)
                            {
                                    Write-Warning "
                                    `n
                                    Unable to retrieve Provider Status for Provider $($Provider.Id)`
                                    "
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "Unable to retrieve Provider Status for Provider $($Provider.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "Unable to retrieve Provider Status for Provider $($Provider.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "Unable to retrieve Provider Status for Provider $($Provider.Id)"
                                    }
                            }
                            ElseIf($? -and $Null -eq $ProviderStatus)
 
  <>                                 Write-Host "
                                    No Provider Status retrieved for Provider $($Provider.Id)`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No Provider Status retrieved for Provider $($Provider.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No Provider Status retrieved for Provider $($Provider.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No Provider Status retrieved for Provider $($Provider.Id)"
                                    }
                            }
                            Else
                            {
                                    $FullProviderStatus = GetRASStatus $ProviderStatus.AgentState
     
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 3 0 "Providers"
                                    }
                                    If($Text)
                                    {
                                            Line 2 "Providers"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 3 0 "Providers"
                                    }
     
                                    $VDIType = GetVDIType $Provider.Type
                                    
                                    Switch($ProviderStatus.HighAvailabilityState)
                                    {
                                            "Off"           {$HAMode = "Off"; Break}
                                            "On_Pref"       {$HAMode = "On Preferred"; Break}
                                            "On_Auto"       {$HAMode = "On Auto"; Break}
                                            Default         {$HAMode = "Unable to determine High Availability mode: $($ProviderStatus.HighAvailabilityState)"; Break}
                                    }
                                    
                                    If($MSWord -or $PDF)
                                    {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Status"; Value = $FullProviderStatus; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $Provider.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Provider Agent"; Value = $Provider.VDIAgent; }) > $Null
                                            $ScriptInformation.Add(@{Data = "High availability"; Value = $HAMode; }) > $Null
                                            If($VDIType -like "*azure*")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Tenant ID"; Value = $Provider.VDIAzureCloudInfo.TenantID; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Subscription ID"; Value = $Provider.VDIAzureCloudInfo.SubscriptionID; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "Application ID"; Value = $Provider.VDIUsername; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Log level"; Value = $ProviderStatus.LogLevel; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Provider.AdminLastMod; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Modified on"; Value = $Provider.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created by"; Value = $Provider.AdminCreate; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created on"; Value = $Provider.TimeCreate.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "ID"; Value = $Provider.Id.ToString(); }) > $Null
                                $cnt = -1    
                                ForEach($line in $ThemePostLogonMessage)                                           $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    If($Text)
 
  <>                                         Line 3 "Name`t`t`t: " $Provider.Name
                                            Line 3 "Status`t`t`t: " $FullProviderStatus
                                            Line 3 "Type`t`t`t: " $VDIType
                                            Line 3 "Description`t`t: " $Provider.Description
                                            Line 3 "Provider Agent`t`t: " $Provider.VDIAgent
                                            Line 3 "High availability`t: " $HAMode
                                            If($VDIType -like "*azure*")
                                            {
                                                    Line 3 "Tenant ID`t`t: " $Provider.VDIAzureCloudInfo.TenantID
                                                    Line 3 "Subscription ID`t`t: " $Provider.VDIAzureCloudInfo.SubscriptionID
                                            }
                                            Line 3 "Application ID`t`t: " $Provider.VDIUsername
                                            Line 3 "Log level`t`t: " $ProviderStatus.LogLevel
                                            Line 3 "Last modification by`t: " $Provider.AdminLastMod
                                            Line 3 "Modified on`t`t: " $Provider.TimeLastMod.ToString()
                                            Line 3 "Created by`t`t: " $Provider.AdminCreate
                                            Line 3 "Created on`t`t: " $Provider.TimeCreate.ToString()
                                            Line 3 "ID`t`t`t: " $Provider.Id.ToString()
                                            Line 0 ""
                                    }
                                    If($HTML)
                                    {
                                            $rowdata = @()
                                            $columnHeaders = @("Name",($Script:htmlsb),$Provider.Name,$htmlwhite)
                                            $rowdata += @(,("Status",($Script:htmlsb),$FullProviderStatus,$htmlwhite))
                                            $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))
                                            $rowdata += @(,("Description",($Script:htmlsb),$Provider.Description,$htmlwhite))
                                            $rowdata += @(,("Provider Agent",($Script:htmlsb),$Provider.VDIAgent,$htmlwhite))
                                            If($VDIType -like "*azure*")
                                            {
                                                    $rowdata += @(,("Tenant ID",($Script:htmlsb),$Provider.VDIAzureCloudInfo.TenantID,$htmlwhite))
                                                    $rowdata += @(,("Subscription ID",($Script:htmlsb),$Provider.VDIAzureCloudInfo.SubscriptionID,$htmlwhite))
                                            }
                                            $rowdata += @(,("Application ID",($Script:htmlsb),$Provider.VDIUsername,$htmlwhite))
                                            $rowdata += @(,("Log level",($Script:htmlsb),$ProviderStatus.LogLevel,$htmlwhite))
                                            $rowdata += @(,("Last modification by",($Script:htmlsb), $Provider.AdminLastMod,$htmlwhite))
                                            $rowdata += @(,("Modified on",($Script:htmlsb), $Provider.TimeLastMod.ToString(),$htmlwhite))
                                            $rowdata += @(,("Created by",($Script:htmlsb), $Provider.AdminCreate,$htmlwhite))
                                            $rowdata += @(,("Created on",($Script:htmlsb), $Provider.TimeCreate.ToString(),$htmlwhite))
                                            $rowdata += @(,("Id",($Script:htmlsb),$Provider.Id.ToString(),$htmlwhite))
                                        $cnt++    
                                            $msg = ""
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
                            }
                                                                  
                            #General
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "General"
                            }
                                        If($cnt -eq 0)                           If($Text)
                            {
                                    Line 3 "General"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If(validobject $Provider PreferredBrokerId)
                            {
                                    $HostPA = Get-RASBroker -Id $Provider.PreferredBrokerId -EA 0 4>$Null
                            }
                            Else
                            {
                                    $HostPA = $Null
                                    $DedicatedVDIAgent = $False
                            }
                            
                            If($? -and -$Null -ne $HostPA)
                            {
                                    If(validobject $HostPA Server)
                                    {
                                            If($Provider.VDIAgent -eq $HostPa.Server)
 
  <>                                                 $DedicatedVDIAgent = $False
                                            }
                                            Else
                                            {
                                                    $DedicatedVDIAgent = $True
                                            }
                                    }
                                    Else
                                    {
                                            $DedicatedVDIAgent = $False
                                    }
                            }
                            ElseIf($? -and $Null -eq $HostPA)
                            {
                                    $DedicatedVDIAgent = $False
                            }
                            Else
                            {
                                    $DedicatedVDIAgent = $False
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Enable provider in site"; Value = $Provider.Enabled.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null
                                    If($VDIType -eq "Azure")
                                    {
                                                $ScriptInformation.Add(@{Data = "Post-logon message:"; Value = $line; }) > $Null                                           $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $Provider.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Subscription details"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Authentication URL"; Value = $Provider.VDIAzureCloudInfo.AuthenticationURL; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Management URL"; Value = $Provider.VDIAzureCloudInfo.ManagementURL; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Resource URI"; Value = $Provider.VDIAzureCloudInfo.ResourceURI; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Tenant ID"; Value = $Provider.VDIAzureCloudInfo.TenantID; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Subscription ID"; Value = $Provider.VDIAzureCloudInfo.SubscriptionID; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null                                           $ScriptInformation.Add(@{Data = "Host"; Value = $Provider.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Port"; Value = $Provider.VDIPort.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $Provider.Description; }) > $Null
                                        }                                   }
                                    $ScriptInformation.Add(@{Data = "Dedicated Provider Agent"; Value = $DedicatedVDIAgent.ToString(); }) > $Null
                                    If($DedicatedVDIAgent)
                                    {
                                            $ScriptInformation.Add(@{Data = "Agent address"; Value = $Provider.VDIAgent; }) > $Null
 
                                $cnt = -1 <>                                 Line 4 "Enable provider in site`t`t: " $Provider.Enabled.ToString()
                                ForEach($line in $ThemePostLogonMessage)                                   Line 4 "Type`t`t`t`t: " $VDIType
                                    If($VDIType -eq "Azure")
 
                                        $cnt++ <>                                         Line 4 "Name`t`t`t`t: " $Provider.Name
                                                                                  Line 4 "Description`t`t`t: " $Provider.Description
                                        If($cnt -eq 0)                                           Line 4 "Subscription details`t`t: "
                                        {                                           Line 5 "Authentication URL: " $Provider.VDIAzureCloudInfo.AuthenticationURL
                                                Line 3 "Post-logon message: " $line                                           Line 5 "Management URL`t  : " $Provider.VDIAzureCloudInfo.ManagementURL
                                            Line 5 "Resource URI`t  : " $Provider.VDIAzureCloudInfo.ResourceURI
                                            Line 4 "Tenant ID`t`t`t: " $Provider.VDIAzureCloudInfo.TenantID
                                            Line 4 "Subscription ID`t`t`t: " $Provider.VDIAzureCloudInfo.SubscriptionID
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                Line 5 "    " $line                                           Line 4 "Host`t`t`t`t: " $Provider.Server
                                            Line 4 "Port`t`t`t`t: " $Provider.VDIPort.ToString()
                                            Line 4 "Description`t`t`t: " $Provider.Description
                                        }                                   }
                                    Line 4 "Dedicated Provider Agent`t: " $DedicatedVDIAgent.ToString()
                                    If($DedicatedVDIAgent)
                                    {
                                            Line 4 "Agent address`t`t`t: " $Provider.VDIAgent
 
                                $cnt = -1 <>  
                                ForEach($line in $ThemePostLogonMessage)    
                                {    
                                        $cnt++    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $columnHeaders = @("Post-logon message:",($Script:htmlsb),$line,$htmlwhite)                                   $columnHeaders = @("Enable provider in site",($Script:htmlsb),$Provider.Enabled.ToString(),$htmlwhite)
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))                                   $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))
                                        }                                   If($VDIType -eq "Azure")
                                }    
     
                                $msg = "Messages"    
                                $columnWidths = @("200","400")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {                                   {
                                WriteWordLine 4 0 "HTML5 client/URLs"                                           $rowdata += @(,( "Name",($Script:htmlsb), $Provider.Name,$htmlwhite))
                        }    
                        If($Text)    
                        {    
                                Line 2 "HTML5 client/URLs"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                    
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $rowdata += @(,( "Description",($Script:htmlsb), $Provider.Description,$htmlwhite))
                                $ScriptInformation.Add(@{Data = "Theme login page:"; Value = $ThemeHTML5URL; }) > $Null                                           $rowdata += @(,( "Subscription details",($Script:htmlsb), "",$htmlwhite))
                                $ScriptInformation.Add(@{Data = "Show Parallels Client download URL"; Value = $ThemeShowDownloadURL; }) > $Null                                           $rowdata += @(,( "     Authentication URL",($Script:htmlsb), $Provider.VDIAzureCloudInfo.AuthenticationURL,$htmlwhite))
                                $ScriptInformation.Add(@{Data = "Override download URL for branded Parallels Client (Windows)"; Value = $ThemeOverrideDownloadURL; }) > $Null                                           $rowdata += @(,( "     Management URL",($Script:htmlsb), $Provider.VDIAzureCloudInfo.ManagementURL,$htmlwhite))
                                            $rowdata += @(,( "     Resource URI",($Script:htmlsb), $Provider.VDIAzureCloudInfo.ResourceURI,$htmlwhite))
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           $rowdata += @(,( "Tenant ID",($Script:htmlsb), $Provider.VDIAzureCloudInfo.TenantID,$htmlwhite))
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                                    
                                If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty    
                                {    
                                        WriteWordLine 4 0 "Footer URLs:"    
                                        [System.Collections.Hashtable[]] $URLWordTable = @();    
                                            
                                        ForEach($FooterURL in $ThemeFooterURLs)    
                                        {    
                                                $URLTableRowHash = @{    
                                                URL     = $FooterURL.URL;    
                                                Text    = $FooterURL.Text;    
                                                Tooltip = $FooterURL.Tooltip;    
                                                }    
                                                $URLWordTable += $URLTableRowHash;    
                                        }    
     
                                        If($URLWordTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $URLWordTable `    
                                                -Columns  URL,Text,Tooltip `    
                                                -Headers  "URL","Text","Tooltip"`    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 150;    
                                                $Table.Columns.Item(2).Width = 150;    
                                                $Table.Columns.Item(3).Width = 150;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           $rowdata += @(,( "Subscription ID",($Script:htmlsb), $Provider.VDIAzureCloudInfo.SubscriptionID,$htmlwhite))
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
 
                                        WriteWordLine 0 1 "There are no Footer URLs" <>                                         $rowdata += @(,("Host",($Script:htmlsb),$Provider.Server,$htmlwhite))
                                }                                                 $rowdata += @(,("Port",($Script:htmlsb),$Provider.VDIPort.ToString(),$htmlwhite))
                        }                                           $rowdata += @(,("Description",($Script:htmlsb),$Provider.Description,$htmlwhite))
                        If($Text)    
                        {    
                                Line 3 "Theme login page`t`t  : " $ThemeHTML5URL    
                                Line 3 "Show Parallels Client download URL: " $ThemeShowDownloadURL    
                                Line 3 "Override download URL for branded "    
                                Line 3 "Parallels Client (Windows)`t  : " $ThemeOverrideDownloadURL    
                                Line 0 ""    
     
                                If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty    
                                {    
                                        Line 3 "Footer URLs:"    
                                        Line 3 "URL                             Text                            Tooltip                       "    
                                        Line 3 "=============================================================================================="    
                                        #       123456789012345678901234567890SS123456789012345678901234567890SS123456789012345678901234567890    
     
                                        ForEach($FooterURL in $ThemeFooterURLs)    
                                        {    
                                                Line 3 ( "{0,-30}  {1,-30}  {2,-30}" -f `    
                                                $FooterURL.URL, $FooterURL.Text, $FooterURL.Tooltip)    
                                        }    
                                            
                                        Line 0 ""    
 
                                Else <>                                 $rowdata += @(,("Dedicated Provider Agent",($Script:htmlsb),$DedicatedVDIAgent.ToString(),$htmlwhite))
                                    If($DedicatedVDIAgent)
 
                                        Line 3 "There are no Footer URLs" <>                                         $rowdata += @(,("Agent address",($Script:htmlsb),$Provider.VDIAgent,$htmlwhite))
                                }                                          }
                        }    
                        If($HTML)    
                        {    
                                $ThemeName = $Theme.Name.Replace("<","").Replace(">","")    
                                $rowdata = @()    
                                $columnHeaders = @("Theme login page:",($Script:htmlsb),$ThemeHTML5URL,$htmlwhite)    
                                $rowdata += @(,("Show Parallels Client download URL",($Script:htmlsb),$ThemeShowDownloadURL,$htmlwhite))    
                                $rowdata += @(,("Override download URL for branded Parallels Client (Windows)",($Script:htmlsb),$ThemeOverrideDownloadURL,$htmlwhite))    
 
                                $msg = "HTML5 client/URLs" <>                                 $msg = "General"
                                $columnWidths = @("200","400")                                   $columnWidths = @("200","275")
 
  <>  
                                If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty    
                                {    
                                        $rowdata = @()    
     
                                        ForEach($FooterURL in $ThemeFooterURLs)    
                                        {    
                                                $rowdata += @(,(    
                                                $FooterURL.URL,$htmlwhite,    
                                                $FooterURL.Text,$htmlwhite,    
                                                $FooterURL.Tooltip,$htmlwhite))    
                                        }                           }
                            
                                        $columnHeaders = @(                           #Credentials
                                        "URL",($Script:htmlsb),    
                                        "Text",($Script:htmlsb),    
                                        "Tooltip",($Script:htmlsb))    
     
                                        $msg = "Footer URLs:"    
                                        $columnWidths = @("150","150","150")    
                                        FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "450"    
                                        WriteHTMLLine 0 0 ""    
                                }    
                                Else    
                                {    
                                        WriteHTMLLine 0 1 "There are no Footer URLs"    
                                }           
                        }    
 
                                WriteWordLine 4 0 "HTML5 client/Branding" <>                                 WriteWordLine 4 0 "Credentials"
 
                                Line 2 "HTML5 client/Branding" <>                                 Line 3 "Credentials"
 
                                $ScriptInformation.Add(@{Data = "Webpage title"; Value = $Theme.HTML5Client.Branding.WebpageTitle; }) > $Null <>                                 If($VDIType -eq "Azure")
                                $ScriptInformation.Add(@{Data = "Login to"; Value = $Theme.HTML5Client.Branding.LoginTo; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Company logo"; Value = $ThemeCompanyLogo; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Favicon icon"; Value = $ThemeFaviconIcon; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Webpage title`t: " $Theme.HTML5Client.Branding.WebpageTitle    
                                Line 3 "Login to`t: " $Theme.HTML5Client.Branding.LoginTo    
                                Line 3 "Company logo`t: " $ThemeCompanyLogo    
                                Line 3 "Favicon icon`t: " $ThemeFaviconIcon    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Webpage title",($Script:htmlsb),$Theme.HTML5Client.Branding.WebpageTitle,$htmlwhite)    
                                $rowdata += @(,("Login to",($Script:htmlsb),$Theme.HTML5Client.Branding.LoginTo,$htmlwhite))    
                                $rowdata += @(,("Company logo",($Script:htmlsb),$ThemeCompanyLogo,$htmlwhite))    
                                $rowdata += @(,("Favicon icon",($Script:htmlsb),$ThemeFaviconIcon,$htmlwhite))    
     
                                $msg = "HTML5 client/Branding"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "HTML5 client/Language bar"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "HTML5 client/Language bar"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Default language"   ; Value = $Theme.HTML5Client.LanguageBar.Default.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "English"            ; Value = $Theme.HTML5Client.LanguageBar.en_US.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "German"             ; Value = $Theme.HTML5Client.LanguageBar.de_DE.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Japanese"           ; Value = $Theme.HTML5Client.LanguageBar.ja_JP.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Russian"            ; Value = $Theme.HTML5Client.LanguageBar.ru_RU.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "French"             ; Value = $Theme.HTML5Client.LanguageBar.fr_FR.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Spanish"            ; Value = $Theme.HTML5Client.LanguageBar.es_ES.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Italian"            ; Value = $Theme.HTML5Client.LanguageBar.it_IT.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Portuguese"         ; Value = $Theme.HTML5Client.LanguageBar.pt_BR.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Chinese Simplified" ; Value = $Theme.HTML5Client.LanguageBar.zh_CN.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Chinese Traditional"; Value = $Theme.HTML5Client.LanguageBar.zh_TW.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Korean"             ; Value = $Theme.HTML5Client.LanguageBar.ko_KR.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Dutch"              ; Value = $Theme.HTML5Client.LanguageBar.nl_NL.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Default language`t: "    $Theme.HTML5Client.LanguageBar.Default.ToString()    
                                Line 3 "English`t`t`t: "         $Theme.HTML5Client.LanguageBar.en_US.ToString()    
                                Line 3 "German`t`t`t: "          $Theme.HTML5Client.LanguageBar.de_DE.ToString()    
                                Line 3 "Japanese`t`t: "          $Theme.HTML5Client.LanguageBar.ja_JP.ToString()    
                                Line 3 "Russian`t`t`t: "         $Theme.HTML5Client.LanguageBar.ru_RU.ToString()    
                                Line 3 "French`t`t`t: "          $Theme.HTML5Client.LanguageBar.fr_FR.ToString()    
                                Line 3 "Spanish`t`t`t: "         $Theme.HTML5Client.LanguageBar.es_ES.ToString()    
                                Line 3 "Italian`t`t`t: "         $Theme.HTML5Client.LanguageBar.it_IT.ToString()    
                                Line 3 "Portuguese`t`t: "        $Theme.HTML5Client.LanguageBar.pt_BR.ToString()    
                                Line 3 "Chinese Simplified`t: "  $Theme.HTML5Client.LanguageBar.zh_CN.ToString()    
                                Line 3 "Chinese Traditional`t: " $Theme.HTML5Client.LanguageBar.zh_TW.ToString()    
                                Line 3 "Korean`t`t`t: "          $Theme.HTML5Client.LanguageBar.ko_KR.ToString()    
                                Line 3 "Dutch`t`t`t: "           $Theme.HTML5Client.LanguageBar.nl_NL.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Default language",($Script:htmlsb),$Theme.HTML5Client.LanguageBar.Default.ToString(),$htmlwhite)    
                                $rowdata += @(,("English"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.en_US.ToString(),$htmlwhite))    
                                $rowdata += @(,("German"             ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.de_DE.ToString(),$htmlwhite))    
                                $rowdata += @(,("Japanese"           ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.ja_JP.ToString(),$htmlwhite))    
                                $rowdata += @(,("Russian"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.ru_RU.ToString(),$htmlwhite))    
                                $rowdata += @(,("French"             ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.fr_FR.ToString(),$htmlwhite))    
                                $rowdata += @(,("Spanish"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.es_ES.ToString(),$htmlwhite))    
                                $rowdata += @(,("Italian"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.it_IT.ToString(),$htmlwhite))    
                                $rowdata += @(,("Portuguese"         ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.pt_BR.ToString(),$htmlwhite))    
                                $rowdata += @(,("Chinese Simplified" ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.zh_CN.ToString(),$htmlwhite))    
                                $rowdata += @(,("Chinese Traditional",($Script:htmlsb),$Theme.HTML5Client.LanguageBar.zh_TW.ToString(),$htmlwhite))    
                                $rowdata += @(,("Korean"             ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.ko_KR.ToString(),$htmlwhite))    
                                $rowdata += @(,("Dutch"              ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.nl_NL.ToString(),$htmlwhite))    
     
                                $msg = "HTML5 client/Language bar"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "HTML5 client/Messages"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "HTML5 client/Messages"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $cnt = -1    
                                ForEach($line in $ThemeHTML5PrelogonMessage)    
 
                                        $cnt++ <>  
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Pre-logon message:"; Value = $line; }) > $Null                                           $ScriptInformation.Add(@{Data = "Application ID"; Value = $Provider.VDIUsername; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null    
                                        }    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
     
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Override post-logon message"; Value = $Theme.HTML5Client.Message.OverridePostLogonMessage.ToString(); }) > $Null    
                                If($Theme.HTML5Client.Message.OverridePostLogonMessage)    
 
                                        ForEach($line in $ThemeHTML5PostlogonMessage) <>  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null                                           $ScriptInformation.Add(@{Data = "Username"; Value = $Provider.VDIUsername; }) > $Null
                                        }    
 
                                $cnt = -1 <>                                 If($VDIType -eq "Azure")
                                ForEach($line in $ThemeHTML5PrelogonMessage)    
 
                                        $cnt++ <>  
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "Pre-logon message: " $line                                           Line 4 "Application ID: " $Provider.VDIUsername
                                        }                                   }
                                        Else                                   Else
                                        {    
                                                Line 5 "    " $line    
                                        }    
                                }    
                                Line 0 ""    
     
                                Line 3 "Override post-logon message: " $Theme.HTML5Client.Message.OverridePostLogonMessage.ToString()    
                                If($Theme.HTML5Client.Message.OverridePostLogonMessage)    
 
                                        ForEach($line in $ThemeHTML5PostlogonMessage) <>                                         Line 4 "Username`t`t`t: " $Provider.VDIUsername
                                        {    
                                                Line 5 "    " $line    
                                        }    
 
                                $cnt = -1 <>                                 If($VDIType -eq "Azure")
                                ForEach($line in $ThemeHTML5PrelogonMessage)    
 
                                        $cnt++ <>  
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $columnHeaders = @("Pre-logon message:",($Script:htmlsb),$line,$htmlwhite)                                           $columnHeaders = @("Application ID",($Script:htmlsb),$Provider.VDIUsername,$htmlwhite)
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))                                           $columnHeaders = @("Username",($Script:htmlsb),$Provider.VDIUsername,$htmlwhite)
                                        }    
 
                                $msg = "HTML5 client/Messages" <>                                 $msg = "Credentials"
                                $columnWidths = @("200","400")                                   $columnWidths = @("200","275")
 
  <>  
                                $rowdata = @()    
                                $columnHeaders = @("Override post-logon message",($Script:htmlsb),$Theme.HTML5Client.Message.OverridePostLogonMessage.ToString(),$htmlwhite)    
                                If($Theme.HTML5Client.Message.OverridePostLogonMessage)    
                                {    
                                        ForEach($line in $ThemeHTML5PostlogonMessage)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))    
                                        }                           }
                                }    
 
                                $msg = "" <>                         #Agent Settings
                                $columnWidths = @("200","400")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
 
                                WriteWordLine 4 0 "HTML5 client/Gateway" <>                                 WriteWordLine 4 0 "Agent settings"
 
                                Line 2 "HTML5 client/Gateway" <>                                 Line 3 "Agent settings"
 
                        If($MSWord -or $PDF) <>                         <#
                            Switch ($Provider.DragAndDropMode)
 
                                $ScriptInformation = New-Object System.Collections.ArrayList <>  
                                $ScriptInformation.Add(@{Data = "Override gateway settings for theme"; Value = $Theme.HTML5Client.Gateway.OverrideGWSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Client"; Value = ""; }) > $Null                                   "Bidirectional"         {$VDIDragAndDrop = "Bidirectional";
                                $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $ThemeHTML5LaunchSessionsUsing; }) > $Null                                   $VDIAllowDragAndDrop = "True";
                                Switch($Theme.HTML5Client.Gateway.LaunchMethod)                                   Break}
                                    "Disabled"                      {$VDIDragAndDrop = "Disabled"; 
                                    $VDIAllowDragAndDrop = "False";
                                    Break}
                                    "ClientToServer"        {$VDIDragAndDrop = "Client to server only"; 
                                    $VDIAllowDragAndDrop = "True";
                                    Break}
                                    "ServerToClient"        {$VDIDragAndDrop = "Server to client only"; 
                                    $VDIAllowDragAndDrop = "True";
                                    Break}
                                    Default                         {$VDIDragAndDrop = "Unable to determine Drag and drop: $($Provider.DragAndDropMode)"; 
                                    $VDIAllowDragAndDrop = "False";
                                    Break}
                            }
                            
                            #>
                            $VDIDragAndDrop = ""
                            $VDIAllowDragAndDrop = ""
     
                            If(validobject $Provider AllowURLAndMailRedirection)
                                {                           {
                                        "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"                                     Switch($Provider.AllowURLAndMailRedirection)
                                        {                                   {
                                            "Enabled"                                               {$VDIAllowClientURLMailRedirection = "Enabled"; 
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                            "Disabled"                                              {$VDIAllowClientURLMailRedirection = "Disabled"; 
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                            "EnabledWithAppRegistration"    {$VDIAllowClientURLMailRedirection = "Enabled";
                                                                                                             $ReplaceRegisteredApplication = "True";
                                                                                                             Break}
                                                $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $Theme.HTML5Client.Gateway.AllowLaunchMethod.ToString(); }) > $Null                                           Default                                                 {$VDIAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($Provider.AllowURLAndMailRedirection)";
                                                $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(); }) > $Null                                                                                                            $ReplaceRegisteredApplication = "False";
                                                Break                                                                                                            Break}
                                        }                                   }
                                        "Launch_Applications_with_Parallels_Client"                                                                        }
                            Else
                                        {                           {
                                                Break                                   $VDIAllowClientURLMailRedirection = ""
                                    $ReplaceRegisteredApplication = "";
                                        }                           }
                                        "Launch_Applications_with_Browser_HTML5"                                                                          
                            If(validobject $Provider FileTransferMode)
                                        {                           {
                                                $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(); }) > $Null                                   Switch ($Provider.FileTransferMode)
                                                Break                                   {
                                            "Bidirectional"         {$ProviderFileTransferMode = "Bidirectional"; Break}
                                            "Disabled"                      {$ProviderFileTransferMode = "Disabled"; Break}
                                            "ClientToServer"        {$ProviderFileTransferMode = "Client to server only"; Break}
                                            "ServerToClient"        {$ProviderFileTransferMode = "Server to client only"; Break}
                                            Default                         {$ProviderFileTransferMode = "Unable to determine File Transfer mode: $($Provider.FileTransferMode)"; Break}
                                        }                                   }
                                }                           }
                                $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $Theme.HTML5Client.Gateway.Pre2000Cred.ToString(); }) > $Null                           Else
                                $ScriptInformation.Add(@{Data = "     Allow embedding of Parallels HTML5 Client into other web pages"; Value = $Theme.HTML5Client.Gateway.AllowEmbed.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow file transfer command"; Value = $ThemeHTMLFileTransfer; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow clipboard command"; Value = $ThemeHTMLClipboardDirection; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $Theme.HTML5Client.Gateway.AllowCORS.ToString(); }) > $Null    
                                If($Theme.HTML5Client.Gateway.AllowCORS)    
                                {                           {
                                    $ProviderFileTransferMode = ""
                            }
                                        $cnt=-1    
                                        ForEach($Domain in $Theme.HTML5Client.Gateway.AllowedDomainsForCORS)                           If(validobject $Provider FileTransferLocation)
                                        {                           {
                                                $cnt++                                   If($Provider.FileTransferLocation -eq "")
                                                    
                                                If($cnt -eq 0)    
                                                {                                   {
                                                        $ScriptInformation.Add(@{Data = "Allow domains"; Value = $Domain; }) > $Null                                           $ProviderFileTransferLocation = "Default download location"
                                                }                                   }
                                                Else                                   Else
                                                {                                   {
                                            $ProviderFileTransferLocation = $ProviderHost.FileTransferLocation
                                    }
                            }
                            Else
                            {
                                    $ProviderFileTransferLocation = ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $Provider.VDIAgent; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Allow Client URL/Mail Redirection"; Value = $VDIAllowClientURLMailRedirection; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Replace registered application"; Value = $ReplaceRegisteredApplication; }) > $Null
                                    If(validobject $Provider SupportShellURLNamespaceObjects)
                                    {
                                            $ScriptInformation.Add(@{Data = "     Support Windows Shell URL namespace objects"; Value = $Provider.SupportShellURLNamespaceObjects.ToString(); }) > $Null
                                    }
                                    $ScriptInformation.Add(@{Data = "Enable Drag and drop"; Value = $VDIAllowDragAndDrop; }) > $Null
                                                        $ScriptInformation.Add(@{Data = ""; Value = $Domain; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Direction"; Value = $VDIDragAndDrop; }) > $Null
                                    If(validobject $Provider AllowFileTransfer)
                                    {
                                            $ScriptInformation.Add(@{Data = "Allow file transfer command (Web (HTML5) and Chrome clients)"; Value = $Provider.AllowFileTransfer.ToString(); }) > $Null
                                                }                                   }
                                    $ScriptInformation.Add(@{Data = "     Configure File Transfer"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Direction"; Value = $ProviderFileTransferMode; }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Location"; Value = $ProviderFileTransferLocation; }) > $Null
                                    If(validobject $Provider FileTransferLockLocation)
                                    {
                                            $ScriptInformation.Add(@{Data = "          Do not allow to change location"; Value = $Provider.FileTransferLockLocation.ToString(); }) > $Null
                                        }                                   }
                                    If(validobject $Provider EnableDriveRedirectionCache)
                                    {
                                        $ScriptInformation.Add(@{Data = "Browser cache time"; Value = "$($Theme.HTML5Client.Gateway.BrowserCacheTimeInMonths.ToString()) months"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Enable drive redirection cache"; Value = $Provider.EnableDriveRedirectionCache.ToString(); }) > $Null
 
                                Line 3 "Override gateway settings for theme: " $Theme.HTML5Client.Gateway.OverrideGWSettings.ToString() <>                                 Line 4 "Preferred Connection Broker`t`t`t`t`t: " $Provider.VDIAgent
                                Line 3 "Client"                                   Line 4 "Allow Client URL/Mail Redirection`t`t`t`t: " $VDIAllowClientURLMailRedirection
                                Line 4 "Launch sessions using`t`t`t: " $ThemeHTML5LaunchSessionsUsing                                   Line 5 "Replace registered application`t`t`t`t: " $ReplaceRegisteredApplication
                                Switch($Theme.HTML5Client.Gateway.LaunchMethod)                                   If(validobject $Provider SupportShellURLNamespaceObjects)
 
                                        "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"   <>  
                                        {    
                                                Line 4 "Allow user to select a launch method`t: " $Theme.HTML5Client.Gateway.AllowLaunchMethod.ToString()                                           Line 5 "Support Windows Shell URL namespace objects`t`t: " $Provider.SupportShellURLNamespaceObjects.ToString()
                                                Line 4 "Allow opening applications in a new tab`t: " $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString()    
                                                Break    
                                        }                                   }
                                        "Launch_Applications_with_Parallels_Client"                                                                                Line 4 "Enable Drag and drop`t`t`t`t`t`t: " $VDIAllowDragandDrop
                                        {                                   Line 5 "Direction`t`t`t`t`t`t: " $VDIDragAndDrop
                                                Break                                   If(validobject $Provider AllowFileTransfer)
                                        }    
                                        "Launch_Applications_with_Browser_HTML5"                                                    
                                        {                                   {
                                                Line 4 "Allow opening applications in a new tab`t: " $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString()                                           Line 4 "Allow file transfer command (Web (HTML5) and Chrome clients)`t: " $Provider.AllowFileTransfer.ToString()
                                                Break    
                                        }    
 
                                Line 4 "Use Pre Windows 2000 login format`t: " $Theme.HTML5Client.Gateway.Pre2000Cred.ToString() <>  
                                Line 4 "Allow embedding of Parallels HTML5 "                                   Line 5 "Configure File Transfer"
                                Line 4 "Client into other web pages`t`t: " $Theme.HTML5Client.Gateway.AllowEmbed.ToString()    
                                Line 4 "Allow file transfer command`t`t: " $ThemeHTMLFileTransfer                                   Line 6 "Direction`t`t`t: " $ProviderFileTransferMode
                                Line 4 "Allow clipboard command`t`t`t: " $ThemeHTMLClipboardDirection                                   Line 6 "Location`t`t`t: " $ProviderFileTransferLocation
                                Line 4 "Allow cross-origin resource sharing`t: " $Theme.HTML5Client.Gateway.AllowCORS.ToString()                                   If(validobject $Provider FileTransferLockLocation)
                                If($Theme.HTML5Client.Gateway.AllowCORS)    
 
                                        $cnt=-1 <>  
                                        ForEach($Domain in $Theme.HTML5Client.Gateway.AllowedDomainsForCORS)                                           Line 6 "Do not allow to change location : " $Provider.FileTransferLockLocation.ToString()
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 5 "Allow domains`t`t`t: " $Domain    
                                                }                                   }
                                                Else                                   If(validobject $Provider EnableDriveRedirectionCache)
                                                {                                   {
                                                        Line 9 "  " $Domain    
                                                }    
                                        }    
                                        Line 5 "Browser cache time`t`t: "  "$($Theme.HTML5Client.Gateway.BrowserCacheTimeInMonths.ToString()) months"                                           Line 4 "Enable drive redirection cache`t`t`t`t`t: " $Provider.EnableDriveRedirectionCache.ToString()
 
  <>                                 
 
                                $columnHeaders = @("Override gateway settings for theme",($Script:htmlsb),$Theme.HTML5Client.Gateway.OverrideGWSettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Preferred Connection Broker",($Script:htmlsb),$Provider.VDIAgent,$htmlwhite)
                                $rowdata += @(,("Client",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Allow Client URL/Mail Redirection",($Script:htmlsb),$VDIAllowClientURLMailRedirection,$htmlwhite))
                                $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$ThemeHTML5LaunchSessionsUsing,$htmlwhite))                                   $rowdata += @(,("     Replace registered application",($Script:htmlsb),$ReplaceRegisteredApplication,$htmlwhite))
                                Switch($Theme.HTML5Client.Gateway.LaunchMethod)                                   If(validobject $Provider SupportShellURLNamespaceObjects)
 
                                        "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"   <>  
                                        {    
                                                $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$Theme.HTML5Client.Gateway.AllowLaunchMethod.ToString(),$htmlwhite))                                           $rowdata += @(,("     Support Windows Shell URL namespace objects",($Script:htmlsb),$Provider.SupportShellURLNamespaceObjects.ToString(),$htmlwhite))
                                                $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))    
                                                Break    
                                        }                                   }
                                        "Launch_Applications_with_Parallels_Client"                                                                                $rowdata += @(,("Enable Drag and drop",($Script:htmlsb),$VDIAllowDragAndDrop,$htmlwhite))
                                        {                                   $rowdata += @(,("     Directon",($Script:htmlsb),$VDIDragAndDrop,$htmlwhite))
                                                Break                                   If(validobject $Provider AllowFileTransfer)
                                        }    
                                        "Launch_Applications_with_Browser_HTML5"                                                    
                                        {                                   {
                                                $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))                                           $rowdata += @(,("Allow file transfer command (Web (HTML5) and Chrome clients)",($Script:htmlsb),$Provider.AllowFileTransfer.ToString(),$htmlwhite))
                                                Break    
                                        }    
 
                                $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb), $Theme.HTML5Client.Gateway.Pre2000Cred.ToString(),$htmlwhite)) <>  
                                $rowdata += @(,("     Allow embedding of Parallels HTML5 Client into other web pages",($Script:htmlsb), $Theme.HTML5Client.Gateway.AllowEmbed.ToString(),$htmlwhite))    
                                $rowdata += @(,("     Allow file transfer command",($Script:htmlsb),$ThemeHTMLFileTransfer,$htmlwhite))                                   $rowdata += @(,("     Configure File Transfer",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("     Allow clipboard command",($Script:htmlsb),$ThemeHTMLClipboardDirection,$htmlwhite))                                   $rowdata += @(,("          Direction",($Script:htmlsb),$ProviderFileTransferMode,$htmlwhite))
                                $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$Theme.HTML5Client.Gateway.AllowCORS.ToString(),$htmlwhite))                                   $rowdata += @(,("          Location",($Script:htmlsb),$ProviderFileTransferLocation,$htmlwhite))
                                If($Theme.HTML5Client.Gateway.AllowCORS)                                   If(validobject $Provider FileTransferLockLocation)
 
                                        $cnt=-1 <>  
                                        ForEach($Domain in $Theme.HTML5Client.Gateway.AllowedDomainsForCORS)    
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Allow domains",($Script:htmlsb),$Domain,$htmlwhite))                                           $rowdata += @(,("          Do not allow to change location",($Script:htmlsb),$Provider.FileTransferLockLocation.ToString(),$htmlwhite))
                                                }                                   }
                                                Else                                   If(validobject $Provider EnableDriveRedirectionCache)
                                                {                                   {
                                                        $rowdata += @(,("",($Script:htmlsb),$Domain,$htmlwhite))    
                                                }    
                                        }    
                                        $rowdata += @(,("Browser cache time",($Script:htmlsb),"$($Theme.HTML5Client.Gateway.BrowserCacheTimeInMonths.ToString()) months",$htmlwhite))                                           $rowdata += @(,("Enable drive redirection cache",($Script:htmlsb),$Provider.EnableDriveRedirectionCache.ToString(),$htmlwhite))
 
  -+                                 
 
                                $msg = "HTML5 client/Gateway" <>                                 $msg = "Agent settings"
                                $columnWidths = @("300","300")                                   $columnWidths = @("200","275")
 
  -+                         #RDP Printer
                            
 
                                WriteWordLine 4 0 "HTML5 client/Legal policies" <>                                 WriteWordLine 4 0 "RDP printer"
 
                                Line 2 "HTML5 client/Legal policies" <>                                 Line 3 "RDP printer"
 
                        If($MSWord -or $PDF) <>  
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList                           If(validobject $Provider PrinterNameFormat)
                                $ScriptInformation.Add(@{Data = "Cookie consent"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Enable cookie consent"; Value = $Theme.HTML5Client.LegalPolicies.AllowCookieConsent.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "End User License Agreement"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Enable EULA"; Value = $Theme.HTML5Client.LegalPolicies.AllowEULA.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
 
                                Line 3 "Cookie consent"  <>                                 Switch ($Provider.PrinterNameFormat)
                                Line 4 "Enable cookie consent`t: " $Theme.HTML5Client.LegalPolicies.AllowCookieConsent.ToString()    
                                Line 3 "End User License Agreement"     
                                Line 4 "Enable EULA`t`t: " $Theme.HTML5Client.LegalPolicies.AllowEULA.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {                                   {
                                $rowdata = @()                                           "PrnFormat_PRN_CMP_SES" {$ProviderPrinterNameFormat = "Printername (from Computername) in Session no."; Break}
                                $columnHeaders = @("Cookie consent",($Script:htmlsb),"",$htmlwhite)                                           "PrnFormat_SES_CMP_PRN" {$ProviderPrinterNameFormat = "Session no. (Computername from) Printername"; Break}
                                $rowdata += @(,("     Enable cookie consent",($Script:htmlsb),$Theme.HTML5Client.LegalPolicies.AllowCookieConsent.ToString(),$htmlwhite))                                           "PrnFormat_PRN_REDSES"  {$ProviderPrinterNameFormat = "Printername (redirected Session no.)"; Break}
                                $rowdata += @(,("End User License Agreement",($Script:htmlsb),"",$htmlwhite))                                           Default                                 {$ProviderPrinterNameFormat = "Unable to determine RDP Printer Name Format: $($Provider.PrinterNameFormat)"; Break}
                                $rowdata += @(,("     Enable EULA",($Script:htmlsb), $Theme.HTML5Client.LegalPolicies.AllowEULA.ToString(),$htmlwhite))    
     
                                $msg = "HTML5 client/Legal policies"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }                                   }
     
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Windows client/Branding"    
 
                        If($Text) <>  
                        {                           Else
                                Line 2 "Windows client/Branding"    
                        }    
                        If($HTML)    
 
                                #Nothing <>                                 $ProviderPrinterNameFormat = ""
 
                        If($MSWord -or $PDF) <>                         If(validobject $Provider RemoveSessionNumberFromPrinterName)
 
                                $ScriptInformation = New-Object System.Collections.ArrayList <>                                 $ProviderRemoveSessionNumberFromPrinter = $Provider.RemoveSessionNumberFromPrinterName.ToString()
                                $ScriptInformation.Add(@{Data = "Company name"; Value = $Theme.WindowsClient.Branding.CompanyName; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Application name"; Value = $Theme.WindowsClient.Branding.ApplicationName; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Connection banner"; Value = $ThemeConnectionBanner; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Application icon"; Value = $ThemeApplicationIcon; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
 
                        If($Text) <>  
                        {                           Else
                                Line 3 "Company name`t`t: " $Theme.WindowsClient.Branding.CompanyName    
                                Line 3 "Application name`t: " $Theme.WindowsClient.Branding.ApplicationName    
                                Line 3 "Connection banner`t: " $ThemeConnectionBanner    
                                Line 3 "Application icon`t: " $ThemeApplicationIcon    
                                Line 0 ""    
                        }    
                        If($HTML)    
 
                                $rowdata = @() <>                                 $ProviderRemoveSessionNumberFromPrinter = ""
                                $columnHeaders = @("Company name",($Script:htmlsb),$Theme.WindowsClient.Branding.CompanyName,$htmlwhite)    
                                $rowdata += @(,("Application name",($Script:htmlsb),$Theme.WindowsClient.Branding.ApplicationName,$htmlwhite))    
                                $rowdata += @(,("Connection banner",($Script:htmlsb),$ThemeConnectionBanner,$htmlwhite))    
                                $rowdata += @(,("Application icon",($Script:htmlsb),$ThemeApplicationIcon,$htmlwhite))    
     
                                $msg = "Windows client/Branding"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
 
                        If($MSWord -or $PDF) <>                         If(validobject $Provider RemoveClientNameFromPrinterName)
 
                                WriteWordLine 4 0 "Windows client/Messages" <>                                 $ProviderRemoveClientNameFromPrinter = $Provider.RemoveClientNameFromPrinterName.ToString()
 
                        If($Text) <>  
                        {                           Else
                                Line 2 "Windows client/Messages"    
                        }    
                        If($HTML)    
 
                                #Nothing <>                                 $ProviderRemoveClientNameFromPrinter = ""
 
                         <>  
 
  <>                                 $ScriptInformation.Add(@{Data = "RDP Printer Name Format"; Value = $ProviderPrinterNameFormat; }) > $Null
                                $ScriptInformation.Add(@{Data = "Override post-logon message"; Value = $Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Remove session number from printer name"; Value = $ProviderRemoveSessionNumberFromPrinter; }) > $Null
                                If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)                                   If($Provider.RemoveSessionNumberFromPrinterName)
 
                                        ForEach($line in $ThemeWindowsPostlogonMessage) <>  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null                                           $ScriptInformation.Add(@{Data = "Remove client name from printer name"; Value = $ProviderRemoveClientNameFromPrinter; }) > $Null
                                        }    
 
                                Line 3 "Override post-logon message: " $Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString() <>                                 Line 4 "RDP Printer Name Format`t`t`t`t: " $ProviderPrinterNameFormat
                                If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)                                   Line 4 "Remove session number from printer name`t`t: " $ProviderRemoveSessionNumberFromPrinter
                                    If($Provider.RemoveSessionNumberFromPrinterName)
 
                                        ForEach($line in $ThemeWindowsPostlogonMessage) <>                                         Line 4 "Remove client name from printer name`t`t`t: " $ProviderRemoveClientNameFromPrinter
                                        {    
                                                Line 5 "    " $line    
                                        }    
 
  <>                                 $columnHeaders = @("RDP Printer Name Format",($Script:htmlsb),$ProviderPrinterNameFormat,$htmlwhite)
                                $columnHeaders = @("Override post-logon message",($Script:htmlsb),$Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString(),$htmlwhite)                                   $rowdata += @(,("Remove session number from printer name",($Script:htmlsb),$ProviderRemoveSessionNumberFromPrinter,$htmlwhite))
                                If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)                                   If($Provider.RemoveSessionNumberFromPrinterName)
 
                                        ForEach($line in $ThemeWindowsPostlogonMessage) <>                                         $rowdata += @(,("Remove client name from printer name",($Script:htmlsb),$ProviderRemoveClientNameFromPrinter,$htmlwhite))
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))    
                                        }    
 
                                $msg = "Windows client/Messages" <>                                 $msg = "RDP printer"
                                $columnWidths = @("200","400")                                   $columnWidths = @("200","275")
 
  <>                 }
            }
            
            #Remote PCs are not in PoSH
            
            $Gateways = Get-RASGateway -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Gateways for Site $($Site.Name)`
                    "
                        If($MSWord -or $PDF)                   If($MSWord -or $PDF)
                        {                   {
                                WriteWordLine 4 0 "Windows client/Custom menu"                           WriteWordLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)"
                        }                   }
                        If($Text)                   If($Text)
                        {                   {
                            Line 0 "Unable to retrieve Gateways for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $Gateways)
            {
                    Write-Host "
                    No Gateways retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Gateways retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Gateways retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Gateways retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    If($MSWord -or $PDF)
                    {
                                Line 2 "Windows client/Custom menu"                           WriteWordLine 2 0 "Gateways"
                        }                   }
                    If($Text)
                    {
                            Line 1 "Gateways"
                    }
                        If($HTML)                   If($HTML)
                        {                   {
                                #Nothing                           WriteHTMLLine 2 0 "Gateways"
                        }                   }
     
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Gateways"
                    ForEach($Gateway in $Gateways)
                    {
                            $GatewayStatus = Get-RASGatewayStatus -Id $Gateway.Id -EA 0 4>$Null
 
  <>                         If(!$?)
                            {
                                    Write-Warning "
                                    `n
                                    Unable to retrieve Gateway Status for Gateway $($Gateway.Id)`
                                    "
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "Unable to retrieve Gateway Status for Gateway $($Gateway.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "Unable to retrieve Gateway Status for Gateway $($Gateway.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "Unable to retrieve Gateway Status for Gateway $($Gateway.Id)"
                                    }
                                    #unable to retrieve
                                    $GatewayEnableHSTS            = "Unable to retrieve Gateway Status"
                                    $GatewayEnableSSL             = "Unable to retrieve Gateway Status"
                                    $GatewayEnableSSLOnPort       = "Unable to retrieve Gateway Status"
                                    $GatewayAcceptedSSLVersions   = "Unable to retrieve Gateway Status"
                                    $GatewayCipherStrength        = "Unable to retrieve Gateway Status"
                                    $GatewayCipher                = "Unable to retrieve Gateway Status"
                                    $GatewayCertificates          = "Unable to retrieve Gateway Status"
                                    $GatewayHSTSMaxage            = "Unable to retrieve Gateway Status"
                                    $GatewayHSTSIncludeSubdomains = "Unable to retrieve Gateway Status"
                                    $GatewayHSTSPreload           = "Unable to retrieve Gateway Status"
                            }
                            ElseIf($? -and $Null -eq $GatewayStatus)
 
  <>                                 Write-Host "
                                    No Gateway Status retrieved for Gateway $($Gateway.Id)`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No Gateway Status found for Gateway $($Gateway.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No Gateway Status found for Gateway $($Gateway.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No Gateway Status found for Gateway $($Gateway.Id)"
                                    }
                                    #set all to blank
                                    $GatewayEnableHSTS            = ""
                                    $GatewayEnableSSL             = ""
                                    $GatewayEnableSSLOnPort       = ""
                                    $GatewayAcceptedSSLVersions   = ""
                                    $GatewayCipherStrength        = ""
                                    $GatewayCipher                = ""
                                    $GatewayCertificates          = ""
                                    $GatewayHSTSMaxage            = ""
                                    $GatewayHSTSIncludeSubdomains = ""
                                    $GatewayHSTSPreload           = ""
                            }
                            Else
                            {
                                    If($Gateway.InheritDefaultSslTlsSettings)
                                    {
                                            #do we inherit site defaults?
                                            #yes we do, get the default settings for the Site
                                            #use the Site default settings
     
                                            $GatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                            
                                            If($? -and $Null -ne $GatewayDefaults)
                                            {
                                                    If($GatewayDefaults.EnableHSTS)
                                                    {
                                                            $GatewayEnableHSTS            = $GatewayDefaults.EnableHSTS.ToString()
                                                            $GatewayHSTSMaxage            = $GatewayDefaults.HSTSMaxAge.ToString()
                                                            $GatewayHSTSIncludeSubdomains = $GatewayDefaults.HSTSIncludeSubdomains.ToString()
                                                            $GatewayHSTSPreload           = $GatewayDefaults.HSTSPreload.ToString()
                                                    }
                                                    Else
                                                    {
                                                            $GatewayEnableHSTS = $GatewayDefaults.EnableHSTS.ToString()
                                                    }
                                                    $GatewayEnableSSL       = $GatewayDefaults.EnableSSL.ToString()
                                                    $GatewayEnableSSLOnPort = $GatewayDefaults.SSLPort.ToString()
                                                    
                                                    Switch ($GatewayDefaults.MinSSLVersion)
                                                    {
                                                            "SSLv2"         {$GatewayAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}
                                                            "SSLv3"         {$GatewayAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}
                                                            "TLSv1"         {$GatewayAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}
                                                            "TLSv1_1"       {$GatewayAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}
                                                            "TLSv1_2"       {$GatewayAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}
                                                            Default         {$GatewayAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($GatewayDefaults.MinSSLVersion)"; Break}
                                                    }
                                                    
                                                    $GatewayCipherStrength = $GatewayDefaults.CipherStrength.ToString()
                                                    $GatewayCipher         = $GatewayDefaults.Cipher
                                                    
                                                    If($GatewayDefaults.CertificateId -eq 0)
                                                    {
                                                            $GatewayCertificates = "All matching usage"
                                                    }
                                                    Else
                                                    {
                                                            $Results = Get-RASCertificate -Id $GatewayDefaults.CertificateId -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $Results)
                                                            {
                                                                    $GatewayCertificates = $Results.Name
                                                            }
                                                            Else
                                                            {
                                                                    $GatewayCertificates = "Unable to determin Gateway Certificate: $($GatewayDefaults.CertificateId)"
                                                            }
                                                    }
                                            }
                                            Else
                                            {
                                                    #unable to retrieve default, use built-in default values
                                                    $GatewayEnableHSTS          = "False"
                                                    $GatewayEnableSSL           = "True"
                                                    $GatewayEnableSSLOnPort     = "443"
                                                    $GatewayAcceptedSSLVersions = "TLS v1 - TLS v1.2"
                                                    $GatewayCipherStrength      = "High"
                                                    $GatewayCipher              = "EECDH:!SSLv2:!SSLv3:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"
                                                    $GatewayCertificates        = "All matching usage"
                                            }
                                    }
                                    Else
                                    {
                                            #we don't inherit settings
                                            #get the settings configured for this GW
                                            If($Gateway.EnableHSTS)
                                            {
                                                    $GatewayEnableHSTS            = $Gateway.EnableHSTS.ToString()
                                                    $GatewayHSTSMaxage            = $Gateway.HSTSMaxAge.ToString()
                                                    $GatewayHSTSIncludeSubdomains = $Gateway.HSTSIncludeSubdomains.ToString()
                                                    $GatewayHSTSPreload           = $Gateway.HSTSPreload.ToString()
                                            }
                                            Else
                                            {
                                                    $GatewayEnableHSTS = $Gateway.EnableHSTS.ToString()
                                            }
                                            $GatewayEnableSSL       = $Gateway.EnableSSL.ToString()
                                            $GatewayEnableSSLOnPort = $Gateway.SSLPort.ToString()
                                            
                                            Switch ($Gateway.MinSSLVersion)
                                            {
                                                    "SSLv2"         {$GatewayAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}
                                                    "SSLv3"         {$GatewayAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}
                                                    "TLSv1"         {$GatewayAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}
                                                    "TLSv1_1"       {$GatewayAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}
                                                    "TLSv1_2"       {$GatewayAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}
                                                    Default         {$GatewayAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($Gateway.MinSSLVersion)"; Break}
                                            }
                                            
                                            $GatewayCipherStrength = $Gateway.CipherStrength.ToString()
                                            $GatewayCipher         = $Gateway.Cipher
                                            
                                            If($Gateway.CertificateId -eq 0)
                                            {
                                                    $GatewayCertificates = "All matching usage"
                                            }
                                            Else
                                            {
                                                    $Results = Get-RASCertificate -Id $Gateway.CertificateId -EA 0 4>$Null
                                                    
                                                    If($? -and $Null -ne $Results)
                                                    {
                                                            #double replace to remove the < and > from the cert name so it doesn't mess up HTML output
                                                            $GatewayCertificates = $Results.Name.Replace("<","").Replace(">","")    
                                                    }
                                                    Else
                                                    {
                                                            $GatewayCertificates = "Unable to determine Gateway Certificate: $($Gateway.CertificateId)"
                                                    }
                                            }
                                    }
                                    
                                    $GatewayStatusAgentState = GetRASStatus $GatewayStatus.AgentState
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 3 0 "Gateways $($Gateway.Server)"
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Server"; Value = $Gateway.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "Menu item"; Value = $Theme.WindowsClient.CustomMenu.MenuItem; }) > $Null                                           $ScriptInformation.Add(@{Data = "Mode"; Value = $Gateway.Mode; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Status"; Value = $GatewayStatusAgentState; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $Gateway.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Certificate"; Value = $GatewayCertificates; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Log level"; Value = $GatewayStatus.LogLevel; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Gateway.AdminLastMod; }) > $Null
                                $ScriptInformation.Add(@{Data = "Command"; Value = $Theme.WindowsClient.CustomMenu.Command; }) > $Null                                           $ScriptInformation.Add(@{Data = "Modified on"; Value = $Gateway.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created by"; Value = $Gateway.AdminCreate; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created on"; Value = $Gateway.TimeCreate.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "ID"; Value = $Gateway.Id.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Menu item: " $Theme.WindowsClient.CustomMenu.MenuItem                                           Line 2 "Gateways $($Gateway.Server)"
                                            Line 3 "Server`t`t`t: " $Gateway.Server
                                            Line 3 "Mode`t`t`t: " $Gateway.Mode
                                            Line 3 "Status`t`t`t: " $GatewayStatusAgentState
                                            Line 3 "Description`t`t: " $Gateway.Description
                                            Line 3 "Certificate`t`t: " $GatewayCertificates
                                            Line 3 "Log level`t`t: " $GatewayStatus.LogLevel
                                            Line 3 "Last modification by`t: " $Gateway.AdminLastMod
                                Line 3 "Command`t : " $Theme.WindowsClient.CustomMenu.Command                                           Line 3 "Modified on`t`t: " $Gateway.TimeLastMod.ToString()
                                            Line 3 "Created by`t`t: " $Gateway.AdminCreate
                                            Line 3 "Created on`t`t: " $Gateway.TimeCreate.ToString()
                                            Line 3 "ID`t`t`t: " $Gateway.Id.ToString()
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                            WriteHTMLLine 3 0 "Gateways $($Gateway.Server)"
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Menu item",($Script:htmlsb),$Theme.WindowsClient.CustomMenu.MenuItem,$htmlwhite)                                           $columnHeaders = @("Server",($Script:htmlsb),$Gateway.Server,$htmlwhite)
                                $rowdata += @(,("Command",($Script:htmlsb),$Theme.WindowsClient.CustomMenu.Command,$htmlwhite))                                           $rowdata += @(,("Mode",($Script:htmlsb),$Gateway.Mode.ToString(),$htmlwhite))
                                            $rowdata += @(,("Status",($Script:htmlsb),$GatewayStatusAgentState.ToString(),$htmlwhite))
                                            $rowdata += @(,("Description",($Script:htmlsb),$Gateway.Description,$htmlwhite))
                                            $rowdata += @(,("Certificate",($Script:htmlsb),$GatewayCertificates,$htmlwhite))
                                            $rowdata += @(,("Log level",($Script:htmlsb),$GatewayStatus.LogLevel,$htmlwhite))
                                            $rowdata += @(,("Last modification by",($Script:htmlsb), $Gateway.AdminLastMod,$htmlwhite))
                                            $rowdata += @(,("Modified on",($Script:htmlsb), $Gateway.TimeLastMod.ToString(),$htmlwhite))
                                            $rowdata += @(,("Created by",($Script:htmlsb), $Gateway.AdminCreate,$htmlwhite))
                                            $rowdata += @(,("Created on",($Script:htmlsb), $Gateway.TimeCreate.ToString(),$htmlwhite))
                                            $rowdata += @(,("ID",($Script:htmlsb),$Gateway.Id.ToString(),$htmlwhite))
 
                                $msg = "Windows client/Custom menu" <>                                         $msg = ""
                                $columnWidths = @("200","275")                                           $columnWidths = @("300","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
                }                           }
        }    
     
        #Certificates    
     
        $Certs = Get-RASCertificate -Siteid $Site.Id -EA 0 4> $Null    
                                  
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Certificates for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                   WriteWordLine 4 0 "General"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                   Line 2 "General"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                   #Nothing
                }                           }
        }                           
        ElseIf($? -and $Null -eq $Certs)                           Switch ($Gateway.IPVersion)
        {                           {
                Write-Host "                                   "Version4"              {$IPVersion = "Version 4"; Break}
                No Certificates retrieved for Site $($Site.Name).`                                   "Version6"              {$IPVersion = "Version 6"; Break}
                " -ForegroundColor White                                   "BothVersions"  {$IPVersion = "Both version 4 & 6"; Break}
                If($MSWord -or $PDF)                                   Default                 {$IPVersion = "Unable to determine IP version: $($Gateway.IPVersion)"; Break}
                            }
                            
                            $GatewayIPs = $Gateway.IPs.Split(";")
                            
                            If($Gateway.BindV4Addresses -eq "")
                {                           {
                        WriteWordLine 0 0 "No Certificates retrieved for Site $($Site.Name)"                                   $GatewayBindV4Addresses = "All available addresses"
                }                           }
                If($Text)                           Else
                {                           {
                        Line 0 "No Certificates retrieved for Site $($Site.Name)"                                   $GatewayBindV4Addresses = $Gateway.BindV4Addresses
                }                           }
                If($HTML)    
                            If($Gateway.OptimizeConnectionIPv4 -eq "<All>")
                {                           {
                        WriteHTMLLine 0 0 "No Certificates retrieved for Site $($Site.Name)"                                   $GatewayOptimizeV4 = "All available addresses"
                }                           }
                            ElseIf($Gateway.OptimizeConnectionIPv4 -eq "<None>")
                            {
                                    $GatewayOptimizeV4 = "None from the available"
        }                           }
        Else                           Else
        {                           {
                If($MSWord -or $PDF)                                   $GatewayOptimizeV4 = $Gateway.OptimizeConnectionIPv4
                            }
     
                            If($Gateway.BindV6Addresses -eq "")
                {                           {
                        WriteWordLine 2 0 "Certificates"                                   $GatewayBindV6Addresses = "All available addresses"
                }                           }
                If($Text)                           Else
                {                           {
                        Line 1 "Certificates"                                   $GatewayBindV6Addresses = $Gateway.BindV6Addresses
                }                           }
                If($HTML)    
                            If($Gateway.OptimizeConnectionIPv6 -eq "<All>")
                {                           {
                        WriteHTMLLine 2 0 "Certificates"                                   $GatewayOptimizeV6 = "All available addresses"
                }                           }
                            ElseIf($Gateway.OptimizeConnectionIPv6 -eq "<None>")
                            {
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Certificates"                                   $GatewayOptimizeV6 = "None from the available"
                ForEach($Cert in $Certs)                           }
                            Else
                {                           {
                                    $GatewayOptimizeV6 = $Gateway.OptimizeConnectionIPv6
                            }
     
 
                                WriteWordLine 3 0 "Certificate $($Cert.Name)" +-  
 
                                $ScriptInformation.Add(@{Data = "Name"; Value = $Cert.Name; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Enable RAS Secure Client Gateway in Site"; Value = $Gateway.Enabled.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Status"; Value = $Cert.Status.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Server"; Value = $Gateway.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "Expiration date"; Value = $Cert.ExpirationDate; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $Gateway.Description; }) > $Null
                                $ScriptInformation.Add(@{Data = "Usage"; Value = $Cert.Usage; }) > $Null                                   $ScriptInformation.Add(@{Data = "IP version"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "Common name"; Value = $Cert.CommonName; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Use IP version"; Value = $IPVersion; }) > $Null
 
                                $cnt=-1 <>                                 $cnt = -1
                                ForEach($Item in $Cert.AlternateNames)                                   ForEach($Item in $GatewayIPs)
 
                                         <>  
                                        If($cnt -eq 0)                                           If($cnt -eq 0 )
 
                                                $ScriptInformation.Add(@{Data = "Alternate Names"; Value = $Item; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "     IP(s)"; Value = $Item; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Cert.AdminLastMod; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Bind to IP"; Value = ""; }) > $Null
                                    If($Gateway.IPVersion -ne "Version6")
                                    {
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $Cert.TimeLastMod.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "     Bind to the following IPv4"; Value = $GatewayBindV4Addresses; }) > $Null
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $Cert.AdminCreate; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $GatewayOptimizeV4; }) > $Null
                                    }
                                    If($Gateway.IPVersion -ne "Version4")
                                    {
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $Cert.TimeCreate.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "     Bind to the following IPv6"; Value = $GatewayBindV6Addresses; }) > $Null
                                $ScriptInformation.Add(@{Data = "ID"; Value = $Cert.Id.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $GatewayOptimizeV6; }) > $Null
                                    }
 
                                Line 2 "Certificate $($Cert.Name)" <>                                 Line 3 "Enable RAS Secure Client Gateway in Site: " $Gateway.Enabled.ToString()
                                Line 3 "Name`t`t`t: " $Cert.Name                                   Line 3 "Server`t`t`t`t`t: " $Gateway.Server
                                Line 3 "Status`t`t`t: " $Cert.Status.ToString()    
                                Line 3 "Expiration date`t`t: " $Cert.ExpirationDate                                   Line 3 "Description`t`t`t`t: " $Gateway.Description
                                    Line 3 "IP version" ""
                                Line 3 "Usage`t`t`t: " $Cert.Usage                                   Line 4 "Use IP version`t`t`t: " $IPVersion
                                Line 3 "Common name`t`t: " $Cert.CommonName    
 
                                $cnt=-1 <>                                 $cnt = -1
                                ForEach($Item in $Cert.AlternateNames)                                   ForEach($Item in $GatewayIPs)
 
                                         <>  
                                        If($cnt -eq 0)                                           If($cnt -eq 0 )
 
                                                Line 3 "Alternate Names`t`t: " $Item <>                                                 Line 4 "IP(s)`t`t`t`t: " $Item
 
                                                Line 6 "  " $Item <>                                                 Line 8 "  " $Item
 
  <>                                 Line 3 "Bind to IP" ""
                                    If($Gateway.IPVersion -ne "Version6")
                                    {
                                Line 3 "Last modification by`t: " $Cert.AdminLastMod                                           Line 4 "Bind to the following IPv4`t: " $GatewayBindV4Addresses
                                            Line 4 "Remove system buffers for`t: " $GatewayOptimizeV4
                                    }
                                    If($Gateway.IPVersion -ne "Version4")
                                    {
                                Line 3 "Modified on`t`t: " $Cert.TimeLastMod.ToString()                                           Line 4 "Bind to the following IPv6`t: " $GatewayBindV6Addresses
                                Line 3 "Created by`t`t: " $Cert.AdminCreate                                           Line 4 "Remove system buffers for`t: " $GatewayOptimizeV6
                                Line 3 "Created on`t`t: " $Cert.TimeCreate.ToString()                                   }
                                Line 3 "ID`t`t`t: " $Cert.Id.ToString()    
 
                                $CertName = $Cert.Name.Replace("<","").Replace(">","") +-  
                                WriteHTMLLine 3 0 "Certificate $CertName"    
 
                                $columnHeaders = @("Name",($Script:htmlsb),$CertName,$htmlwhite) <>                                 $columnHeaders = @("Enable RAS Secure Client Gateway in Site",($Script:htmlsb),$Gateway.Enabled.ToString(),$htmlwhite)
                                $rowdata += @(,("Status",($Script:htmlsb),$Cert.Status.ToString(),$htmlwhite))                                   $rowdata += @(,("Server",($Script:htmlsb),$Gateway.Server,$htmlwhite))
                                $rowdata += @(,("Expiration date",($Script:htmlsb),$Cert.ExpirationDate,$htmlwhite))                                   $rowdata += @(,("Description",($Script:htmlsb),$Gateway.Description,$htmlwhite))
                                $rowdata += @(,("Usage",($Script:htmlsb),$Cert.Usage,$htmlwhite))                                   $rowdata += @(,("IP version",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("Common name",($Script:htmlsb),$Cert.CommonName,$htmlwhite))                                   $rowdata += @(,("     Use IP version",($Script:htmlsb),$IPVersion,$htmlwhite))
 
                                $cnt=-1 <>                                 $cnt = -1
                                ForEach($Item in $Cert.AlternateNames)                                   ForEach($Item in $GatewayIPs)
 
                                         <>  
                                        If($cnt -eq 0)                                           If($cnt -eq 0 )
 
                                                $rowdata += @(,("Alternate Names",($Script:htmlsb),$Item,$htmlwhite)) <>                                                 $rowdata += @(,("     IP(s)",($Script:htmlsb),$Item,$htmlwhite))
 
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $Cert.AdminLastMod,$htmlwhite)) <>                                 $rowdata += @(,("Bind to IP",($Script:htmlsb),"",$htmlwhite))
                                    If($Gateway.IPVersion -ne "Version6")
                                    {
                                $rowdata += @(,("Modified on",($Script:htmlsb), $Cert.TimeLastMod.ToString(),$htmlwhite))                                           $rowdata += @(,("     Bind to the following IPv4",($Script:htmlsb),$GatewayBindV4Addresses,$htmlwhite))
                                $rowdata += @(,("Created by",($Script:htmlsb), $Cert.AdminCreate,$htmlwhite))                                           $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$GatewayOptimizeV4,$htmlwhite))
                                    }
                                    If($Gateway.IPVersion -ne "Version4")
                                    {
                                $rowdata += @(,("Created on",($Script:htmlsb), $Cert.TimeCreate.ToString(),$htmlwhite))                                           $rowdata += @(,("     Bind to the following IPv6",($Script:htmlsb),$GatewayBindV6Addresses,$htmlwhite))
                                $rowdata += @(,("ID",($Script:htmlsb),$Cert.Id.ToString(),$htmlwhite))                                           $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$GatewayOptimizeV6,$htmlwhite))
                                    }
 
                                $msg = "" <>                                 $msg = "General"
                                $columnWidths = @("200","275")                                   $columnWidths = @("300","275")
 
  -+                         #Mode
                            
 
                                WriteWordLine 4 0 "General" <>                                 WriteWordLine 4 0 "Mode"
 
                                Line 2 "General" <>                                 Line 2 "Mode"
 
                        Switch($Cert.KeySize) <>                         If($Gateway.InheritDefaultModeSettings)
 
                                "KeySize1024"           {$KeySize = "1024"; Break} <>                                 #do we inherit site defaults?
                                "KeySize2048"           {$KeySize = "2048"; Break}                                   #yes we do, get the default settings for the Site
                                "KeySize4096"           {$KeySize = "4096"; Break}                                   #use the Site default settings
                                "KeySizeUnknown"        {$KeySize = ""; Break}    
                                Default                         {$KeySize = "Unable to determine certificate key size: $($Cert.KeySize)"; Break}    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $Cert.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $Cert.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Usage"; Value = $Cert.Usage; }) > $Null    
                                $ScriptInformation.Add(@{Data = "State"; Value = $Cert.Status.ToString(); }) > $Null                                   $GatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                $ScriptInformation.Add(@{Data = "Key size"; Value = $KeySize; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Expiration date"; Value = $Cert.ExpirationDate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Common name"; Value = $Cert.CommonName; }) > $Null    
 
                                $cnt=-1 <>                                 If($? -and $Null -ne $GatewayDefaults)
                                ForEach($Item in $Cert.AlternateNames)    
 
                                        $cnt++ <>                                         $GatewayMode = $GatewayDefaults.Mode.ToString()
                                                                                  $GatewayForwardRequests = $GatewayDefaults.NormalModeForwarding.ToString()
                                        If($cnt -eq 0)                                           If($GatewayMode -eq "Normal")
 
                                                $ScriptInformation.Add(@{Data = "Alternate Names"; Value = $Item; }) > $Null <>                                                 $GatewayServers = $GatewayDefaults.ForwardHttpServers.Split(";")
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null <>                                                 $GatewayServers = $GatewayDefaults.ForwardGatewayServers.Split(";")
 
                                } +-  
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         If($GatewayDefaults.PreferredBrokerId -eq 0)
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
                                            {
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite                                                   $GatewayPreferredPublishingAgent = "Automatically"
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }                                           }
                        If($Text)    
                        {                                           Else
                                Line 3 "Name`t`t`t: " $Cert.Name    
                                Line 3 "Description`t`t: " $Cert.Description    
                                Line 3 "Usage`t`t`t: " $Cert.Usage    
                                Line 3 "State`t`t`t: " $Cert.Status.ToString()    
                                Line 3 "Key size`t`t: " $KeySize    
                                Line 3 "Expiration date`t`t: " $Cert.ExpirationDate    
                                Line 3 "Common name`t`t: " $Cert.CommonName    
                                    
                                $cnt=-1    
                                ForEach($Item in $Cert.AlternateNames)    
                                {                                           {
                                        $cnt++                                                   $GatewayPreferredPublishingAgent = (Get-RASBroker -Id $GatewayDefaults.PreferredBrokerId -EA 0 4>$Null).Server
                                            
                                        If($cnt -eq 0)    
                                        {                                           }
                                                Line 3 "Alternate Names`t`t: " $Item    
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                Line 6 "  " $Item                                           #unable to retrieve default, use built-in default values
                                            $GatewayMode = "Normal"
                                            $GatewayForwardRequests = "False"
                                            $GatewayServers = @("localhost:81")
                                            $GatewayPreferredPublishingAgent = "Automatically"
                                        }                                   }
                                }                           }
                                    
                                Line 0 ""    
                        }                           Else
                        If($HTML)    
 
  <>                                 #we don't inherit settings
                                    #get the settings configured for this GW
                                    $GatewayMode = $Gateway.Mode.ToString()
                                    $GatewayForwardRequests = $Gateway.NormalModeForwarding.ToString()
                                $rowdata = @()                                   If($GatewayMode -eq "Normal")
                                $columnHeaders = @("Name",($Script:htmlsb),$Cert.Name.Replace("<","").Replace(">",""),$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$Cert.Description,$htmlwhite))    
                                $rowdata += @(,("Usage",($Script:htmlsb),$Cert.Usage,$htmlwhite))    
                                $rowdata += @(,("State",($Script:htmlsb),$Cert.Status.ToString(),$htmlwhite))    
                                $rowdata += @(,("Key size",($Script:htmlsb),$KeySize,$htmlwhite))    
                                $rowdata += @(,("Expiration date",($Script:htmlsb),$Cert.ExpirationDate,$htmlwhite))    
                                $rowdata += @(,("Common name",($Script:htmlsb),$Cert.CommonName,$htmlwhite))    
                                    
                                $cnt=-1    
                                ForEach($Item in $Cert.AlternateNames)    
 
                                        $cnt++ <>                                         $GatewayServers = $Gateway.ForwardHttpServers.Split(";")
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Alternate Names",($Script:htmlsb),$Item,$htmlwhite))    
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))                                           $GatewayServers = $Gateway.ForwardGatewayServers.Split(";")
                                        }    
 
                                 <>                        
                                $msg = "General"                                   If($Gateway.PreferredBrokerId -eq 0)
                                $columnWidths = @("200","275")                                   {
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           $GatewayPreferredPublishingAgent = "Automatically"
                                WriteHTMLLine 0 0 ""    
                        }                                   }
                                    Else
                                    {
                                            $GatewayPreferredPublishingAgent = (Get-RASBroker -Id $Gateway.PreferredBrokerId -EA 0 4>$Null).Server
                }                                   }
        }                           }
     
        #Settings    
                                  
        #Auditing - not in PoSH    
     
        #Global logging - not in PoSH    
     
        $FarmSettings = Get-RASFarmSettings -SiteId $Site.Id -ea 0 4>$Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Certificates for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $Gateway.InheritDefaultModeSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Gateway mode"; Value = $GatewayMode; }) > $Null
                }                                   
                If($Text)                                   If($GatewayMode -eq "Normal")
                {                                   {
                        Line 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                           If($GatewayForwardRequests -eq "True")
                }    
                If($HTML)    
                {                                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                                   $ScriptInformation.Add(@{Data = "Forward requests to HTTP Server"; Value = $GatewayForwardRequests; }) > $Null
                }                                                   
        }                                                   $cnt = -1
        ElseIf($? -and $Null -eq $FarmSettings)                                                   ForEach($Item in $GatewayServers)
        {                                                   {
                Write-Host "    
                No Certificates retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {                                                           $cnt++
                        WriteWordLine 0 0 "No Certificates retrieved for Site $($Site.Name)"                                                           $tmparray = $Item.Split(":")
                }                                                           $tmpserver = $tmparray[0]
                                                            $tmpport = $tmparray[1]
                If($Text)                                                           If($cnt -eq 0)
                {                                                           {
                        Line 0 "No Certificates retrieved for Site $($Site.Name)"                                                                   $ScriptInformation.Add(@{Data = "Server(s)"; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null
                }                                                           }
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Certificates retrieved for Site $($Site.Name)"    
                }    
        }    
        Else                                                           Else
        {                                                           {
                If($MSWord -or $PDF)                                                                   $ScriptInformation.Add(@{Data = ""; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null
                {    
                        WriteWordLine 2 0 "Settings"    
                }                                                           }
                If($Text)    
                {    
                        Line 1 "Settings"    
                }                                                   }
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 "Settings"    
                }                                           }
                                            
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Settings"                                           $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $GatewayPreferredPublishingAgent; }) > $Null
        }                                   }
                                                  Else
        If($MSWord -or $PDF)    
        {                                   {
                WriteWordLine 3 0 "URL redirection"    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Do not redirect the following URLs"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "Forward requests to next RAS Secure Client Gateway in chain (cascaded firewall)"; Value = $GatewayForwardRequests; }) > $Null
                                            
                                            If($GatewayForwardRequests -eq "True")
                                            {
                $cnt = -1                                                   $cnt = -1
                ForEach($Item in $FarmSettings.URLBlacklist)                                                   ForEach($Item in $GatewayServers)
                {                                                   {
                        $cnt++                                                           $cnt++
                                                                                  $tmparray = $Item.Split(":")
                                                            $tmpserver = $tmparray[0]
                                                            $tmpport = $tmparray[1]
                        If($Cnt -eq 0)                                                           If($cnt -eq 0)
                        {                                                           {
                                $ScriptInformation.Add(@{Data = "     Url"; Value = $Item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = "Server(s)"; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null
                        }                                                           }
                        Else                                                           Else
                        {                                                           {
                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null
                        }                                                           }
                }                                                   }
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sitess"; Value = $FarmSettings.ReplicateURLRedirection.ToString(); }) > $Null                                           }
                                    }
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
        }                           }
        If($Text)                           If($Text)
        {                           {
                Line 2 "URL redirection"                                   Line 3 "Inherit default settings`t`t: " $Gateway.InheritDefaultModeSettings.ToString()
                Line 3 "Do not redirect the following URLs`t: "                                   Line 3 "Gateway mode`t`t`t`t: " $GatewayMode
                                    If($GatewayMode -eq "Normal")
                                    {
                                            Line 3 "Forward requests to HTTP Server`t`t: " $GatewayForwardRequests
                                            
                $cnt = -1                                           $cnt = -1
                ForEach($Item in $FarmSettings.URLBlacklist)                                           ForEach($Item in $GatewayServers)
                {                                           {
                        $cnt++                                                   $cnt++
                                                                          $tmparray = $Item.Split(":")
                                                    $tmpserver = $tmparray[0]
                                                    $tmpport = $tmparray[1]
                        If($Cnt -eq 0)                                                   If($cnt -eq 0)
                        {                                                   {
                                Line 7 "     Url: " $Item                                                           Line 3 "Server(s)`t`t`t`t: " "Server: $($tmpserver)`tPort: $($tmpport)"
                        }                                                   }
                        Else                                                   Else
                        {                                                   {
                                Line 8 "  " $Item                                                           Line 8 "  " "Server: $($tmpserver)`tPort: $($tmpport)"
                        }                                                   }
                }                                           }
                Line 3 "Settings are replicated to all Sites`t: " $FarmSettings.ReplicateURLRedirection.ToString()                                          
                Line 0 ""                                           Line 3 "Preferred Connection Broker`t`t: " $GatewayPreferredPublishingAgent
        }                                   }
        If($HTML)                                   Else
        {                                   {
                WriteHTMLLine 3 0 "URL redirection"                                           Line 3 "Forward requests to next "
                $rowdata = @()                                           Line 3 "RAS Secure Client Gateway"
                $columnHeaders = @("Do not redirect the following URLs",($Script:htmlsb),"",$htmlwhite)                                           Line 3 "in chain (cascaded firewall)`t`t: " $GatewayForwardRequests
                                            
                $cnt = -1                                           $cnt = -1
                ForEach($Item in $FarmSettings.URLBlacklist)                                           ForEach($Item in $GatewayServers)
                {                                           {
                        $cnt++                                                   $cnt++
                                                                          $tmparray = $Item.Split(":")
                                                    $tmpserver = $tmparray[0]
                                                    $tmpport = $tmparray[1]
                        If($Cnt -eq 0)                                                   If($cnt -eq 0)
                        {                                                   {
                                $rowdata += @(,(    URL",($Script:htmlsb),$Item,$htmlwhite))                                                           Line 3 "Server(s)`t`t`t`t: " "Server: $($tmpserver)`tPort: $($tmpport)"
                        }                                                   }
                        Else                                                   Else
                        {                                                   {
                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))                                                           Line 8 "  " "Server: $($tmpserver)`tPort: $($tmpport)"
                        }                                                   }
                }                                           }
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FarmSettings.ReplicateURLRedirection.ToString(),$htmlwhite))    
     
                $msg = ""    
                $columnWidths = @("200","275")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
     
                WriteHTMLLine 0 0 ""    
        }                                   }
                    
        $RASNotificationHandlers = Get-RASNotification -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve notification handlers information    
                "                                   Line 0 ""
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve notification handlers information"    
                }                           }
                If($Text)    
                {    
                        Line 0 "Unable to retrieve notification handlers information"    
                }    
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve notification handlers information"                                   $rowdata = @()
                }                                   $columnHeaders = @("Inherit default settings",($Script:htmlsb),$Gateway.InheritDefaultModeSettings.ToString(),$htmlwhite)
        }                                   $rowdata += @(,("Gateway mode",($Script:htmlsb),$GatewayMode,$htmlwhite))
        ElseIf($? -and $null -eq $RASNotificationHandlers)                                   If($GatewayMode -eq "Normal")
        {                                   {
                Write-Host "                                           $rowdata += @(,("Forward requests to HTTP Server",($Script:htmlsb),$GatewayForwardRequests,$htmlwhite))
                No notification handlers information was found                                          
                " -ForegroundColor White                                           $cnt = -1
                If($MSWord -or $PDF)                                           ForEach($Item in $GatewayServers)
                {                                           {
                        WriteWordLine 0 0 "No notification handlers information was found"    
                }                                                   $cnt++
                                                    $tmparray = $Item.Split(":")
                                                    $tmpserver = $tmparray[0]
                                                    $tmpport = $tmparray[1]
                If($Text)                                                   If($cnt -eq 0)
                {                                                   {
                        Line 0 "No notification handlers information was found"                                                           $rowdata += @(,("Server(s)",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))
                }                                                   }
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No notification handlers information was found"    
                }    
        }    
        Else                                                   Else
        {                                                   {
                OutputRASNotifications $RASNotificationHandlers                                                           $rowdata += @(,("",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))
        }                                                   }
            
        $RASNotificationScripts = Get-RASNotificationScript -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve notification scripts information    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve notification scripts information"    
                }                                           }
                If($Text)    
                {    
                        Line 0 "Unable to retrieve notification scripts information"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve notification scripts information"    
                }    
        }    
        ElseIf($? -and $null -eq $RASNotificationScripts)    
        {    
                Write-Host "    
                No notification scripts information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No notification scripts information was found"    
                }    
                If($Text)    
                {    
                        Line 0 "No notification scripts information was found"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No notification scripts information was found"    
                }    
        }    
        Else    
        {    
                OutputRASNotificationScripts $RASNotificationScripts    
        }    
                                                          
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 3 0 "Client settings"    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                If($FarmSettings.SendHDIcons)    
                {    
                        $ScriptInformation.Add(@{Data = "Published application icons"; Value = "Send high resolution icons (uses more network bandwidth)"; }) > $Null                                           $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$GatewayPreferredPublishingAgent,$htmlwhite))
                }                                   }
                Else                                   Else
                {                                   {
                        $ScriptInformation.Add(@{Data = "Published application icons"; Value = "Send standard resolution icons"; }) > $Null    
                }    
                $ScriptInformation.Add(@{Data = "Enable overlay icon"; Value = $FarmSettings.EnableOverlayIcons.ToString(); }) > $Null    
                $ScriptInformation.Add(@{Data = "Show password expiration reminder"; Value = $FarmSettings.ShowPasswordExpiry.ToString(); }) > $Null    
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FarmSettings.ReplicateSendHDIcons.ToString(); }) > $Null                                           $rowdata += @(,("Forward requests to next RAS Secure Client Gateway in chain (cascaded firewall)",($Script:htmlsb),$GatewayForwardRequests,$htmlwhite))
                                            
                $Table = AddWordTable -Hashtable $ScriptInformation `    
                -Columns Data,Value `    
                -List `                                           $cnt = -1
                -Format $wdTableGrid `                                           ForEach($Item in $GatewayServers)
                -AutoFit $wdAutoFitFixed;    
     
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                $Table.Columns.Item(1).Width = 200;    
                $Table.Columns.Item(2).Width = 250;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
     
                WriteWordLine 0 0 ""    
        }    
        If($Text)    
        {                                           {
                Line 2 "Client settings"                                                   $cnt++
                If($FarmSettings.SendHDIcons)                                                   $tmparray = $Item.Split(":")
                                                    $tmpserver = $tmparray[0]
                                                    $tmpport = $tmparray[1]
                                                    If($cnt -eq 0)
                {                                                   {
                        Line 3 "Published application icons`t`t: " "Send high resolution icons (uses more network bandwidth)" ""                                                           $rowdata += @(,("Server(s)",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))
                }                                                   }
                Else                                                   Else
                {                                                   {
                        Line 3 "Published application icons`t`t: " "Send standard resolution icons" ""                                                           $rowdata += @(,("",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))
                }                                                   }
                Line 3 "Enable overlay icon`t`t`t: " $FarmSettings.EnableOverlayIcons.ToString()    
                Line 3 "Show password expiration reminder`t: " $FarmSettings.ShowPasswordExpiry.ToString()    
                Line 3 "Settings are replicated to all Sites`t: " $FarmSettings.ReplicateSendHDIcons.ToString()    
                Line 0 ""    
        }                                           }
        If($HTML)    
        {    
                WriteHTMLLine 3 0 "Client settings"    
                $rowdata = @()    
                If($FarmSettings.SendHDIcons)    
                {    
                        $columnHeaders = @("Published application icons",($Script:htmlsb),"Send high resolution icons (uses more network bandwidth)",$htmlwhite)    
                }                                   }
                Else    
                {    
                        $columnHeaders = @("Published application icons",($Script:htmlsb),"Send standard resolution icons",$htmlwhite)    
                }    
                $rowdata += @(,("Enable overlay icon",($Script:htmlsb),$FarmSettings.EnableOverlayIcons.ToString(),$htmlwhite))    
                $rowdata += @(,("Show password expiration reminder",($Script:htmlsb),$FarmSettings.ShowPasswordExpiry.ToString(),$htmlwhite))    
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FarmSettings.ReplicateSendHDIcons.ToString(),$htmlwhite))    
 
                $msg = "" <>                                 $msg = "Mode"
                $columnWidths = @("200","275")                                   $columnWidths = @("300","275")
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
     
                WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
        }                           }
 
        $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id} <>                         #Network
                                  
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve FSLogix Settings information    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve FSLogix Settings information"                                   WriteWordLine 4 0 "Network"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve FSLogix Settings information"                                   Line 2 "Network"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve FSLogix Settings information"                                   #Nothing
                }                           }
        }                           
        ElseIf($? -and $null -eq $FSLogixDeploymentSettings)                           If($Gateway.InheritDefaultNetworkSettings)
        {                           {
                Write-Host "                                   #do we inherit site defaults?
                No FSLogix Settings information was found                                   #yes we do, get the default settings for the Site
                " -ForegroundColor White                                   #use the Site default settings
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No FSLogix Settings information was found"                                   $GatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                }                                   
                If($Text)                                   If($? -and $Null -ne $GatewayDefaults)
                {                                   {
                        Line 0 "No FSLogix Settings information was found"                                           $GatewayEnableRASSecureClientGatewayPort             = $GatewayDefaults.EnableGatewayPort.ToString()
                                            $GatewayRASSecureClientGatewayPort                   = $GatewayDefaults.GatewayPort.ToString()
                                            $GatewayEnableRDPPort                                = $GatewayDefaults.EnableRDP.ToString()
                                            $GatewayRDPPort                                      = $GatewayDefaults.RDPPort.ToString()
                                            $GatewayEnableBroadcastRASSecureClientGatewayAddress = $GatewayDefaults.Broadcast.ToString()
                                            $GatewayEnableRDPUPDDataTunneling                    = $GatewayDefaults.EnableRDPUDP.ToString()
                                            $GatewayEnableDeviceManagerPort                      = $GatewayDefaults.EnableDeviceManagerPort.ToString()
                                            $GatewayDeviceManagerPort                            = "20009"
                                            $GatewayEnableRDPDOSAttackFilter                     = $GatewayDefaults.DOSPro.ToString()
                                            $GatewayCipherPreference                             = $GatewayDefaults.CipherPreference.ToString()
                }                                   }
                If($HTML)                                   Else
                {                                   {
                        WriteHTMLLine 0 0 "No FSLogix Settings information was found"                                           #unable to retrieve default, use built-in default values
                                            $GatewayEnableRASSecureClientGatewayPort             = "True"
                                            $GatewayRASSecureClientGatewayPort                   = "80"
                                            $GatewayEnableRDPPort                                = "False"
                                            $GatewayEnableBroadcastRASSecureClientGatewayAddress = "True"
                                            $GatewayEnableRDPUPDDataTunneling                    = "True"
                                            $GatewayEnableDeviceManagerPort                      = "True"
                                            $GatewayDeviceManagerPort                            = "20009"
                                            $GatewayEnableRDPDOSAttackFilter                     = "True"
                                            $GatewayCipherPreference                             = "True"
                }                                   }
        }                           }
        Else                           Else
        {                           {
                                    #we don't inherit settings
                                    #get the settings configured for this GW
                                    $GatewayEnableRASSecureClientGatewayPort             = $Gateway.EnableGatewayPort.ToString()
                                    $GatewayRASSecureClientGatewayPort                   = $Gateway.GatewayPort.ToString()
                                    $GatewayEnableRDPPort                                = $Gateway.EnableRDP.ToString()
                                    $GatewayRDPPort                                      = $Gateway.RDPPort.ToString()
                                    $GatewayEnableBroadcastRASSecureClientGatewayAddress = $Gateway.Broadcast.ToString()
                                    $GatewayEnableRDPUPDDataTunneling                    = $Gateway.EnableRDPUDP.ToString()
                                    $GatewayEnableDeviceManagerPort                      = $Gateway.EnableDeviceManagerPort.ToString()
                                    $GatewayDeviceManagerPort                            = "20009"
                Switch($FSLogixDeploymentSettings.InstallType)                                   $GatewayEnableRDPDOSAttackFilter                     = $Gateway.DOSPro.ToString()
                {                                   $GatewayCipherPreference                             = $Gateway.CipherPreference.ToString()
                        "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}    
                        "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}    
                        "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}    
                        "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}    
                        Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}    
                }                           }
                                          
                $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL    
                $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath    
                $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName    
                $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate    
                    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 3 0 "Features"    
                        WriteWordLine 4 0 "FSLogix"    
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                        $ScriptInformation.Add(@{Data = "Deployment method"; Value = $FSLogixDeploymentSettingsDeploymentMethod; }) > $Null                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $Gateway.InheritDefaultNetworkSettings.ToString(); }) > $Null
                        If($FSLogixDeploymentSettings.InstallType -eq "Online")                                   $ScriptInformation.Add(@{Data = "Enable RAS Secure Client Gateway Port"; Value = $GatewayEnableRASSecureClientGatewayPort; }) > $Null
                        {                                   $ScriptInformation.Add(@{Data = "RAS Secure Client Gateway Port"; Value = $GatewayRASSecureClientGatewayPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "URL"; Value = $FSLogixDeploymentSettingsInstallOnlineURL; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable RDP Port"; Value = $GatewayEnableRDPPort; }) > $Null
                        }    
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")    
                        {    
                                $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsNetworkDrivePath; }) > $Null                                   $ScriptInformation.Add(@{Data = "RDP Port"; Value = $GatewayRDPPort; }) > $Null
                        }                                   $ScriptInformation.Add(@{Data = "Enable Broadcast RAS Secure Client Gateway Address"; Value = $GatewayEnableBroadcastRASSecureClientGatewayAddress; }) > $Null
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")                                   $ScriptInformation.Add(@{Data = "Enable RDP UDP Data Tunneling"; Value = $GatewayEnableRDPUPDDataTunneling; }) > $Null
                        {                                   $ScriptInformation.Add(@{Data = "Enable Client Manager Port"; Value = $GatewayEnableDeviceManagerPort; }) > $Null
                                $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsInstallerFileName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Client Manager Port"; Value = $GatewayDeviceManagerPort; }) > $Null
                        }    
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable RDP DOS Attack Filter"; Value = $GatewayEnableRDPDOSAttackFilter; }) > $Null
                            
                        $Table = AddWordTable -Hashtable $ScriptInformation `                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 2 "Features"    
                        Line 3 "FSLogix"    
                        Line 4 "Deployment method`t`t`t`t`t: " $FSLogixDeploymentSettingsDeploymentMethod    
                        If($FSLogixDeploymentSettings.InstallType -eq "Online")    
                        {    
                                Line 4 "URL`t`t`t`t`t`t`t: " $FSLogixDeploymentSettingsInstallOnlineURL    
                        }    
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")                                   Line 3 "Inherit default settings`t`t: " $Gateway.InheritDefaultNetworkSettings.ToString()
                        {                                   Line 3 "Enable RAS Secure Client Gateway Port`t: " $GatewayEnableRASSecureClientGatewayPort
                                    Line 3 "RAS Secure Client Gateway Port`t`t: " $GatewayRASSecureClientGatewayPort
                                    Line 3 "Enable RDP Port`t`t`t`t: " $GatewayEnableRDPPort
                                    Line 3 "RDP Port`t`t`t`t: " $GatewayRDPPort
                                    Line 3 "Enable Broadcast RAS Secure "
                                    Line 3 "Client Gateway Address`t`t`t: " $GatewayEnableBroadcastRASSecureClientGatewayAddress
                                    Line 3 "Enable RDP UDP Data Tunneling`t`t: " $GatewayEnableRDPUPDDataTunneling
                                    Line 3 "Enable Client Manager Port`t`t: " $GatewayEnableDeviceManagerPort
                                Line 11 ": " $FSLogixDeploymentSettingsNetworkDrivePath                                   Line 3 "Client Manager Port`t`t`t: " $GatewayDeviceManagerPort
                        }                                   Line 3 "Enable RDP DOS Attack Filter`t`t: " $GatewayEnableRDPDOSAttackFilter
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")    
                        {                                   Line 0 ""
                                Line 11 ": " $FSLogixDeploymentSettingsInstallerFileName    
 
                        Line 4 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString() <>  
                }    
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 3 0 "Features"    
                        $rowdata = @()                                   $rowdata = @()
                        $columnHeaders = @("Deployment method",($Script:htmlsb),$FSLogixDeploymentSettingsDeploymentMethod,$htmlwhite)                                   $columnHeaders = @("Inherit default settings",($Script:htmlsb),$Gateway.InheritDefaultNetworkSettings.ToString(),$htmlwhite)
                        If($FSLogixDeploymentSettings.InstallType -eq "Online")                                   $rowdata += @(,("Enable RAS Secure Client Gateway Port",($Script:htmlsb),$GatewayEnableRASSecureClientGatewayPort,$htmlwhite))
                        {                                   $rowdata += @(,("RAS Secure Client Gateway Port",($Script:htmlsb),$GatewayRASSecureClientGatewayPort,$htmlwhite))
                                $rowdata += @(,("URL",($Script:htmlsb),$FSLogixDeploymentSettingsInstallOnlineURL,$htmlwhite))                                   $rowdata += @(,("Enable RDP Port",($Script:htmlsb),$GatewayEnableRDPPort,$htmlwhite))
                        }    
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")    
                        {    
                                $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsNetworkDrivePath,$htmlwhite))                                   $rowdata += @(,("RDP Port",($Script:htmlsb),$GatewayRDPPort,$htmlwhite))
                        }                                   $rowdata += @(,("Enable Broadcast RAS Secure Client Gateway Address",($Script:htmlsb),$GatewayEnableBroadcastRASSecureClientGatewayAddress,$htmlwhite))
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")                                   $rowdata += @(,("Enable RDP UDP Data Tunneling",($Script:htmlsb),$GatewayEnableRDPUPDDataTunneling,$htmlwhite))
                        {                                   $rowdata += @(,("Enable Client Manager Port",($Script:htmlsb),$GatewayEnableDeviceManagerPort,$htmlwhite))
                                $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsInstallerFileName,$htmlwhite))                                   $rowdata += @(,("Client Manager Port",($Script:htmlsb),$GatewayDeviceManagerPort,$htmlwhite))
                        }    
                        $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))                                   $rowdata += @(,("Enable RDP DOS Attack Filter",($Script:htmlsb),$GatewayEnableRDPDOSAttackFilter,$htmlwhite))
                                            
                        $msg = "FSLogix"                                   $msg = "Network"
                        $columnWidths = @("200","250")                                   $columnWidths = @("300","275")
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                }                           }
        }    
}    
#endregion    
                            #SSL/TLS
#region process load balancing    
Function ProcessLoadBalancing    
{    
        Param([object]$Site)    
                                  
        Write-Verbose "$(Get-Date -Format G): Processing Load Balancing"    
            
        OutputLoadBalancingSectionPage    
            
        Write-Verbose "$(Get-Date -Format G): `tProcessing Load Balancing"    
            
        $results = Get-RASLBSettings -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Load Balancing information    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Load Balancing information"                                   WriteWordLine 4 0 "SSL/TLS"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve Load Balancing information"                                   Line 2 "SSL/TLS"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Load Balancing information"    
                }                                   #Nothing
        }                           }
        ElseIf($? -and $null -eq $results)    
        {                           
                Write-Host "    
                No Load Balancing information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "No Load Balancing information was found"                                   $ScriptInformation = New-Object System.Collections.ArrayList
                }                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $Gateway.InheritDefaultSslTlsSettings.ToString(); }) > $Null
                If($Text)    
                {    
                        Line 0 "No Load Balancing information was found"                                   If($GatewayEnableHSTS -eq "False")
                }    
                If($HTML)    
                {                                   {
                        WriteHTMLLine 0 0 "No Load Balancing information was found"                                           $ScriptInformation.Add(@{Data = "HSTS is off"; Value = ""; }) > $Null
                }                                   }
        }    
        Else                                   Else
        {                                   {
                OutputRASLBSettings $results                                           $ScriptInformation.Add(@{Data = "HSTS is on"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Enforce HTTP strict transport security (HSTS)"; Value = $GatewayEnableHSTS; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Browser caache time"; Value = "$GatewayHSTSMaxage months"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Include subdomains"; Value = $GatewayHSTSIncludeSubdomains; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Preload"; Value = $GatewayHSTSPreload; }) > $Null
        }                                   }
            
                                    $ScriptInformation.Add(@{Data = "Enable SSL"; Value = $GatewayEnableSSL; }) > $Null
                                    $ScriptInformation.Add(@{Data = "on Port"; Value = $GatewayEnableSSLOnPort; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Accepted SSL Versions"; Value = $GatewayAcceptedSSLVersions; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Cipher Strength"; Value = $GatewayCipherStrength; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Cipher"; Value = $GatewayCipher; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Use ciphers according to server preference"; Value = $GatewayCipherPreference; }) > $Null
        $results = Get-RASCPUOptimizationSettings -SiteId $Site.Id -EA 0 4>$Null                                   $ScriptInformation.Add(@{Data = "Certificates"; Value = $GatewayCertificates; }) > $Null
            
        If(!($?))                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
        {    
        Write-Warning "                                   SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
        `n    
        Unable to retrieve CPU Optimization information                                   $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
        "    
                If($MSWord -or $PDF)                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
                {    
                        WriteWordLine 0 0 "Unable to retrieve CPU Optimization information"                                   FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve CPU Optimization information"                                   Line 3 "Inherit default settings`t`t  : " $Gateway.InheritDefaultSslTlsSettings.ToString()
                }    
                If($HTML)                                   If($GatewayEnableHSTS -eq "False")
                {                                   {
                        WriteHTMLLine 0 0 "Unable to retrieve CPU Optimization information"                                           Line 3 "HSTS is off"
                }                                   }
        }                                   Else
        ElseIf($? -and $null -eq $results)    
        {                                   {
                Write-Host "                                           Line 3 "HSTS is on"
                No CPU Optimization information was found                                           Line 3 "Enforce HTTP strict transport security`t  : " $GatewayEnableHSTS
                " -ForegroundColor White                                           Line 3 "Browser caache time`t`t`t  : " "$GatewayHSTSMaxage months"
                If($MSWord -or $PDF)                                           Line 3 "Include subdomains`t`t`t  : " $GatewayHSTSIncludeSubdomains
                {                                           Line 3 "Preload`t`t`t`t`t  : " $GatewayHSTSPreload
                        WriteWordLine 0 0 "No CPU Optimization information was found"    
                }                                   }
                If($Text)    
                {    
                        Line 0 "No CPU Optimization information was found"                                   Line 3 "Enable SSL`t`t`t`t  : " $GatewayEnableSSL
                                    Line 3 "on Port`t`t`t`t`t  : " $GatewayEnableSSLOnPort
                                    Line 3 "Accepted SSL Versions`t`t`t  : " $GatewayAcceptedSSLVersions
                                    Line 3 "Cipher Strength`t`t`t`t  : " $GatewayCipherStrength
                                    Line 3 "Cipher`t`t`t`t`t  : " $GatewayCipher
                                    Line 3 "Use ciphers according to server preference: " $GatewayCipherPreference
                                    Line 3 "Certificates`t`t`t`t  : " $GatewayCertificates
                                    Line 0 ""
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "No CPU Optimization information was found"                                   $rowdata = @()
                                    $columnHeaders = @("Inherit default settings",($Script:htmlsb),$Gateway.InheritDefaultSslTlsSettings.ToString(),$htmlwhite)
     
                                    If($GatewayEnableHSTS -eq "False")
                }                                   {
                                            $rowdata += @(,("HSTS is off",($Script:htmlsb),"",$htmlwhite))
        }                                   }
        Else                                   Else
        {                                   {
                OutputCPUOptimizationSettings $results                                           $rowdata += @(,("HSTS is on",($Script:htmlsb),,$htmlwhite))
                                            $rowdata += @(,("Enforce HTTP strict transport security (HSTS)",($Script:htmlsb),$GatewayEnableHSTS,$htmlwhite))
                                            $rowdata += @(,("Browser caache time",($Script:htmlsb),"$GatewayHSTSMaxage months",$htmlwhite))
                                            $rowdata += @(,("Include subdomains",($Script:htmlsb),$GatewayHSTSIncludeSubdomains,$htmlwhite))
                                            $rowdata += @(,("Preload",($Script:htmlsb),$GatewayHSTSPreload,$htmlwhite))
        }                                   }
     
                                    $rowdata += @(,("Enable SSL",($Script:htmlsb),$GatewayEnableSSL,$htmlwhite))
                                    $rowdata += @(,("on Port",($Script:htmlsb),$GatewayEnableSSLOnPort,$htmlwhite))
                                    $rowdata += @(,("Accepted SSL Versions",($Script:htmlsb),$GatewayAcceptedSSLVersions,$htmlwhite))
                                    $rowdata += @(,("Cipher Strength",($Script:htmlsb),$GatewayCipherStrength,$htmlwhite))
                                    $rowdata += @(,("Cipher",($Script:htmlsb),$GatewayCipher,$htmlwhite))
                                    $rowdata += @(,("Use ciphers according to server preference",($Script:htmlsb),$GatewayCipherPreference,$htmlwhite))
                                    $rowdata += @(,("Certificates",($Script:htmlsb),$GatewayCertificates,$htmlwhite))
     
                                    $msg = "SSL/TLS"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
}                           }
 
Function OutputLoadBalancingSectionPage <>                         #HTML5
{                           
        If($MSWord -or $PDF)                           If($MSWord -or $PDF)
        {                           {
                $Script:Selection.InsertNewPage()    
                WriteWordLine 1 0 "Load Balancing"                                   WriteWordLine 4 0 "User Portal"
        }                           }
        If($Text)                           If($Text)
        {                           {
                Line 0 "Load Balancing"                                   Line 2 "User Portal"
        }                           }
        If($HTML)                           If($HTML)
        {                           {
                WriteHTMLLine 1 0 "Load Balancing"    
        }                                   #Nothing
}                           }
                            
Function OutputRASLBSettings                           If($Gateway.InheritDefaultUserPortalSettings)
{                           {
        Param([object] $RASLBSettings)                                   #do we inherit site defaults?
                                    #yes we do, get the default settings for the Site
                                    #use the Site default settings
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Load Balancing"                                   $GatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                          
        If($MSWord -or $PDF)                                   If($? -and $Null -ne $GatewayDefaults)
        {                                   {
                WriteWordLine 2 0 "Load Balancing"                                           $GatewayEnableUserPortalClient = $GatewayDefaults.EnableUserPortal.ToString()
        }                                           
        If($Text)                                           Switch($GatewayDefaults.LaunchMethod)
        {                                           {
                Line 1 "Load Balancing"                                                   "ParallelsClientAndWebClient"   {$GatewayLaunchSessionsUsing = "Parallels Client with fallback to Browser"; Break}
        }                                                   "ParallelsClient"                               {$GatewayLaunchSessionsUsing = "Parallels Client only"; Break}
        If($HTML)                                                   "WebClient"                                             {$GatewayLaunchSessionsUsing = "Browser Only"; Break}
        {                                                   Default                                                 {$GatewayLaunchSessionsUsing = "Unable to determine Launch sessions using: $($GatewayDefaults.LaunchMethod)"; Break}
                WriteHTMLLine 2 0 "Load Balancing"    
        }                                           }
                                                  
        Switch ($RASLBSettings.Method)                                           Switch ($GatewayDefaults.FileTransferMode)
        {                                           {
                "ResourceBased" {$RASLBSettingsMethod = "Resource Based"; Break}                                                   "Bidirectional        {$GatewayFileTransferMode = "Bidirectional"; Break}
                "RoundRobin"    {$RASLBSettingsMethod = "Round Robin"; Break}                                                   "Disabled"                      {$GatewayFileTransferMode = "Disabled"; Break}
                                                    "ClientToServer"        {$GatewayFileTransferMode = "Client to server only"; Break}
                                                    "ServerToClient"        {$GatewayFileTransferMode = "Server to client only"; Break}
                Default                 {$RASLBSettingsMethod = "Unable to determine Load balancing method: $($RASLBSettings.Method)"; Break}                                                   Default                         {$GatewayFileTransferMode = "Unable to determine File Transfer mode: $($GatewayDefaults.FileTransferMode)"; Break}
        }                                           }
            
        If($MSWord -or $PDF)                                           Switch ($GatewayDefaults.ClipboardDirection)
        {                                           {
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Method"; Value = $RASLBSettingsMethod; }) > $Null    
                $ScriptInformation.Add(@{Data = "Counters"; Value = ""; }) > $Null                                                   "Bidirectional"         {$GatewayClipboardTransferMode = "Bidirectional"; Break}
                $ScriptInformation.Add(@{Data = "     User Sessions"; Value = $RASLBSettings.SessionsCounter; }) > $Null                                                   "Disabled"                      {$GatewayClipboardTransferMode = "Disabled"; Break}
                                                    "ClientToServer"        {$GatewayClipboardTransferMode = "Client to server only"; Break}
                $ScriptInformation.Add(@{Data = "     Memory"; Value = $RASLBSettings.MemoryCounter; }) > $Null                                                   "ServerToClient"        {$GatewayClipboardTransferMode = "Server to client only"; Break}
                $ScriptInformation.Add(@{Data = "     CPU"; Value = $RASLBSettings.CPUCounter; }) > $Null    
                $ScriptInformation.Add(@{Data = "Reconnect to disconnected sessions"; Value = $RASLBSettings.ReconnectDisconnect; }) > $Null    
                $ScriptInformation.Add(@{Data = "Reconnect sessions using client's IP address only"; Value = $RASLBSettings.ReconnectUsingIPOnly; }) > $Null    
                $ScriptInformation.Add(@{Data = "Limit each user to one session per desktop"; Value = $RASLBSettings.ReconnectUser; }) > $Null    
                $ScriptInformation.Add(@{Data = "Disable Microsoft RD Connection Broker"; Value = $RASLBSettings.DisableRDSLB; }) > $Null    
                $ScriptInformation.Add(@{Data = "Declare Agent dead if not responding for"; Value = "$($RASLBSettings.DeadTimeout) seconds"; }) > $Null                                                   Default                         {$GatewayClipboardTransferMode = "Unable to determine Clipboard mode: $($GatewayDefaults.ClipboardDirection)"; Break}
                $ScriptInformation.Add(@{Data = "Agent Refresh Time"; Value = "$($RASLBSettings.RefreshTimeout) seconds"; }) > $Null    
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASLBSettings.Replicate.ToString(); }) > $Null    
     
                $Table = AddWordTable -Hashtable $ScriptInformation `    
                -Columns Data,Value `    
                -List `    
                -Format $wdTableGrid `    
                -AutoFit $wdAutoFitFixed;    
     
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                $Table.Columns.Item(1).Width = 275;    
                $Table.Columns.Item(2).Width = 150;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
                WriteWordLine 0 0 ""    
        }                                           }
        If($Text)    
        {    
                Line 2 "Method`t`t`t: " $RASLBSettingsMethod                                           $GatewayAllowLaunchMethod          = $GatewayDefaults.AllowLaunchMethod.ToString()
                Line 2 "Counters"                                           $GatewayAllowAppsInNewTab          = $GatewayDefaults.AllowAppsInNewTab.ToString()
                Line 3 "User Sessions`t: " $RASLBSettings.SessionsCounter    
                Line 3 "Memory`t`t: " $RASLBSettings.MemoryCounter    
                Line 3 "CPU`t`t: " $RASLBSettings.CPUCounter    
                Line 2 "Reconnect to disconnected sessions`t`t`t: " $RASLBSettings.ReconnectDisconnect    
                Line 2 "Reconnect sessions using client's IP address only`t: " $RASLBSettings.ReconnectUsingIPOnly    
                Line 2 "Limit each user to one session per desktop`t`t: " $RASLBSettings.ReconnectUser    
                Line 2 "Disable Microsoft RD Connection Broker`t`t`t: " $RASLBSettings.DisableRDSLB    
                Line 2 "Declare Agent dead if not responding for`t`t: " "$($RASLBSettings.DeadTimeout) seconds"                                           $GatewayUsePreWin2000LoginFormat   = $GatewayDefaults.UsePreWin2000LoginFormat.ToString()
                Line 2 "Agent Refresh Time`t`t`t`t`t: " "$($RASLBSettings.RefreshTimeout) seconds"                                           $GatewayAllowEmbed                 = $GatewayDefaults.AllowEmbed.ToString()
                                            $GatewayAllowFileTransfer          = $GatewayDefaults.AllowFileTransfer.ToString()
                                            $GatewayAllowClipboard             = $GatewayDefaults.AllowClipboard.ToString()
                                            $GatewayAllowCORS                  = $GatewayDefaults.AllowCORS
                                            $GatewayAllowedDomainsForCORS      = $GatewayDefaults.AllowedDomainsForCORS
                                            $GatewayBrowserCacheTimeInMonths   = $GatewayDefaults.BrowserCacheTimeInMonths
                Line 2 "Settings are replicated to all Sites`t`t`t: " $RASLBSettings.Replicate.ToString()                                           $GatewayEnableAlternateNLBHostname = $GatewayDefaults.EnableAlternateNLBHost.ToString()
                Line 0 ""                                           $GatewayAlternameNLBHostname       = $GatewayDefaults.AlternateNLBHost
                                            $GatewayEnableAlternateNLBPort     = $GatewayDefaults.EnableAlternateNLBPort.ToString()
                                            $GatewayAlternateNLBPort           = $GatewayDefaults.AlternateNLBPort.ToString()
        }                                   }
        If($HTML)                                   Else
        {                                   {
                                            #unable to retrieve default, use built-in default values
                                            $GatewayEnableUserPortalClient     = "True"
                                            $GatewayLaunchSessionsUsing        = "Parallels Client with gallback to Browser"
                                            $GatewayAllowLaunchMethod          = "True"
                                            $GatewayAllowAppsInNewTab          = "False"
                                            $GatewayUsePreWin2000LoginFormat   = "True"
                                            $GatewayAllowEmbed                 = "False"
                                            $GatewayAllowFileTransfer          = "True"
                                            $GatewayAllowClipboard             = "True"
                                            $GatewayAllowCORS                  = "False"
                $rowdata = @()                                           $GatewayAllowedDomainsForCORS      = @()
                $columnHeaders = @("Method",($Script:htmlsb),$RASLBSettingsMethod,$htmlwhite)                                           $GatewayBrowserCacheTimeInMonths   = 12
                $rowdata += @(,("Counters",($Script:htmlsb),"",$htmlwhite))                                           $GatewayEnableAlternateNLBHostname = "False"
                $rowdata += @(,("     User Sessions",($Script:htmlsb),$RASLBSettings.SessionsCounter.ToString(),$htmlwhite))                                           $GatewayAlternameNLBHostname       = ""
                $rowdata += @(,("     Memory",($Script:htmlsb),$RASLBSettings.MemoryCounter.ToString(),$htmlwhite))                                           $GatewayEnableAlternateNLBPort     = "False"
                $rowdata += @(,("     CPU",($Script:htmlsb),$RASLBSettings.CPUCounter.ToString(),$htmlwhite))                                           $GatewayAlternateNLBPort           = "8443"
                $rowdata += @(,("Reconnect to disconnected sessions",($Script:htmlsb),$RASLBSettings.ReconnectDisconnect.ToString(),$htmlwhite))                                           $GatewayClipboardTransferMode      = "Bidirectional"
                $rowdata += @(,("Reconnect sessions using client's IP address only",($Script:htmlsb),$RASLBSettings.ReconnectUsingIPOnly.ToString(),$htmlwhite))    
                $rowdata += @(,("Limit each user to one session per desktop",($Script:htmlsb),$RASLBSettings.ReconnectUser.ToString(),$htmlwhite))    
                $rowdata += @(,("Disable Microsoft RD Connection Broker",($Script:htmlsb),$RASLBSettings.DisableRDSLB.ToString(),$htmlwhite))    
                $rowdata += @(,("Declare Agent dead if not responding for",($Script:htmlsb),"$($RASLBSettings.DeadTimeout) seconds",$htmlwhite))    
                $rowdata += @(,("Agent Refresh Time",($Script:htmlsb),"$($RASLBSettings.RefreshTimeout) seconds",$htmlwhite))    
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASLBSettings.Replicate.ToString(),$htmlwhite))    
     
                $msg = ""    
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }                                   }
}                           }
                            Else
Function OutputCPUOptimizationSettings    
{                           {
        Param([object] $RASCPUSettings)                                   #we don't inherit settings
                                          #get the settings configured for this GW
        Write-Verbose "$(Get-Date -Format G): `t`tOutput CPU Optimization"                                   $GatewayEnableUserPortalClient = $Gateway.EnableUserPortal.ToString()
                                          
        If($MSWord -or $PDF)                                   Switch($GatewayDefaults.LaunchMethod)
        {                                   {
                WriteWordLine 2 0 "CPU Optimization"                                           "ParallelsClientAndWebClient"   {$GatewayLaunchSessionsUsing = "Parallels Client with fallback to Browser"; Break}
                                            "ParallelsClient"                               {$GatewayLaunchSessionsUsing = "Parallels Client only"; Break}
                                            "WebClient"                                             {$GatewayLaunchSessionsUsing = "Browser Only"; Break}
                                            Default                                                 {$GatewayLaunchSessionsUsing = "Unable to determine Launch sessions using: $($GatewayDefaults.LaunchMethod)"; Break}
        }                                   }
        If($Text)                                  
                                    Switch ($GatewayDefaults.FileTransferMode)
        {                                   {
                Line 1 "CPU Optimization"                                           "Bidirectional"         {$GatewayFileTransferMode = "Bidirectional"; Break}
                                            "Disabled"                      {$GatewayFileTransferMode = "Disabled"; Break}
                                            "ClientToServer"        {$GatewayFileTransferMode = "Client to server only"; Break}
                                            "ServerToClient"        {$GatewayFileTransferMode = "Server to client only"; Break}
                                            Default                         {$GatewayFileTransferMode = "Unable to determine File Transfer mode: $($GatewayDefaults.FileTransferMode)"; Break}
        }                                   }
        If($HTML)    
                                    Switch ($GatewayDefaults.ClipboardDirection)
        {                                   {
                WriteHTMLLine 2 0 "CPU Optimization"                                           "Bidirectional"         {$GatewayClipboardTransferMode = "Bidirectional"; Break}
                                            "Disabled"                      {$GatewayClipboardTransferMode = "Disabled"; Break}
                                            "ClientToServer"        {$GatewayClipboardTransferMode = "Client to server only"; Break}
                                            "ServerToClient"        {$GatewayClipboardTransferMode = "Server to client only"; Break}
                                            Default                         {$GatewayClipboardTransferMode = "Unable to determine Clipboard mode: $($GatewayDefaults.ClipboardDirection)"; Break}
        }                                   }
     
                                    $GatewayAllowLaunchMethod          = $Gateway.AllowLaunchMethod.ToString()
                                    $GatewayAllowAppsInNewTab          = $Gateway.AllowAppsInNewTab.ToString()
                                    $GatewayUsePreWin2000LoginFormat   = $Gateway.UsePreWin2000LoginFormat.ToString()
                                    $GatewayAllowEmbed                 = $Gateway.AllowEmbed.ToString()
                                    $GatewayAllowFileTransfer          = $Gateway.AllowFileTransfer
                                    $GatewayAllowClipboard             = $Gateway.AllowClipboard
                                    $GatewayAllowCORS                  = $Gateway.AllowCORS
                                    $GatewayAllowedDomainsForCORS      = $Gateway.AllowedDomainsForCORS
                                    $GatewayBrowserCacheTimeInMonths   = $Gateway.BrowserCacheTimeInMonths
                                    $GatewayEnableAlternateNLBHostname = $Gateway.EnableAlternateNLBHost.ToString()
                                    $GatewayAlternameNLBHostname       = $Gateway.AlternateNLBHost
                                    $GatewayEnableAlternateNLBPort     = $Gateway.EnableAlternateNLBPort.ToString()
                                    $GatewayAlternateNLBPort           = $Gateway.AlternateNLBPort.ToString()
                            }
                                  
        If($MSWord -or $PDF)                           If($MSWord -or $PDF)
        {                           {
                $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                $ScriptInformation.Add(@{Data = "Enable CPU Optimization"; Value = $RASCPUSettings.EnableCPUOptimization.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $Gateway.InheritDefaultUserPortalSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable User Portal"; Value = $GatewayEnableUserPortalClient; }) > $Null
                $ScriptInformation.Add(@{Data = "Start"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Client"; Value = ""; }) > $Null
                $ScriptInformation.Add(@{Data = "     Total CPU usage exceeds"; Value = "$($RASCPUSettings.StartUsage) %"; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $GatewayLaunchSessionsUsing; }) > $Null
                $ScriptInformation.Add(@{Data = "CPU Conditions"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $GatewayAllowLaunchMethod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $GatewayAllowAppsInNewTab; }) > $Null
                $ScriptInformation.Add(@{Data = "     Critical - CPU usage by process exceeds"; Value = "$($RASCPUSettings.CriticalUsage) %"; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $GatewayUsePreWin2000LoginFormat; }) > $Null
                $ScriptInformation.Add(@{Data = "     Idle - CPU usage by process exceeds"; Value = "$($RASCPUSettings.IdleUsage) %"; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow embedding of User Portal into other web pages"; Value = $GatewayAllowEmbed; }) > $Null
     
                $ScriptInformation.Add(@{Data = "Exclusions"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow file transfer command"; Value = $GatewayAllowFileTransfer.ToString(); }) > $Null
                                    If($GatewayAllowFileTransfer)
                                    {
                $ScriptInformation.Add(@{Data = "     Processes that will be excluded from CPU Optimization"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Direction"; Value = $GatewayFileTransferMode; }) > $Null
                                    }
                    
                If($RASCPUSettings.CPUExcludeList.Count -eq 0)                                   $ScriptInformation.Add(@{Data = "     Allow clipboard command"; Value = $GatewayAllowClipboard.ToString(); }) > $Null
                                    If($GatewayAllowClipboard)
                {                                   {
                        $ScriptInformation.Add(@{Data = "          Processes to exclude"; Value = "None"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Clipboard Redirection"; Value = $GatewayClipboardTransferMode; }) > $Null
                }                                   }
                Else    
                                    $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $GatewayAllowCORS.ToString(); }) > $Null
                                    If($GatewayAllowCORS)
                {                                   {
                        $cnt = -1                                           $cnt=-1
                                                                  ForEach($Domain in $GatewayAllowedDomainsForCORS)
                        ForEach($item in $RASCPUSettings.CPUExcludeList)    
                        {                                           {
                                $cnt++                                                   $cnt++
                                                                                  
                                If($cnt -eq 0)                                                   If($cnt -eq 0)
                                {                                                   {
                                        $ScriptInformation.Add(@{Data = "          Processes to exclude"; Value = $item; }) > $Null                                                           $ScriptInformation.Add(@{Data = "     Allow domains"; Value = $Domain; }) > $Null
                                }                                                   }
                                Else                                                   Else
                                {                                                   {
                                        $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = $Domain; }) > $Null
                                }                                                   }
                        }                                           }
                                            $ScriptInformation.Add(@{Data = "     Browser cache time"; Value = "$($GatewayBrowserCacheTimeInMonths.ToString()) months"; }) > $Null
                }                                   }
 
  <>                                 $ScriptInformation.Add(@{Data = "Network Load Balancer access"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Use alternate hostname"; Value = $GatewayEnableAlternateNLBHostname; }) > $Null
                                    If($GatewayEnableAlternateNLBHostname -eq "True")
                                    {
                                            $ScriptInformation.Add(@{Data = ""; Value = $GatewayAlternameNLBHostname; }) > $Null
                                    }
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASCPUSettings.Replicate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "     Use alternate port"; Value = $GatewayEnableAlternateNLBPort; }) > $Null
                                    If($GatewayEnableAlternateNLBPort -eq "True")
                                    {
                                            $ScriptInformation.Add(@{Data = ""; Value = $GatewayAlternateNLBPort; }) > $Null
                                    }
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 275; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 150;                                   $Table.Columns.Item(2).Width = 250;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
        }                           }
        If($Text)                           If($Text)
        {                           {
                Line 2 "Enable CPU Optimization`t`t`t`t`t: " $RASCPUSettings.EnableCPUOptimization.ToString()                                   Line 3 "Inherit default settings`t`t`t: " $Gateway.InheritDefaultUserPortalSettings.ToString()
                Line 2 "Start"    
                Line 3 "Total CPU usage exceeds`t`t`t`t: " "$($RASCPUSettings.StartUsage) %"                                   Line 3 "Enable User Portal`t`t`t`t: " $GatewayEnableUserPortalClient
                Line 2 "CPU Conditions"                                   Line 3 "Client" ""
                Line 3 "Critical - CPU usage by process exceeds`t`t: " "$($RASCPUSettings.CriticalUsage) %"                                   Line 4 "Launch sessions using`t`t`t: " $GatewayLaunchSessionsUsing
                Line 3 "Idle - CPU usage by process exceeds`t`t: " "$($RASCPUSettings.IdleUsage) %"                                   Line 4 "Allow user to select a launch method`t: " $GatewayAllowLaunchMethod
                Line 2 "Exclusions"                                   Line 4 "Allow opening applications in a new tab`t: " $GatewayAllowAppsInNewTab
                                    Line 4 "Use Pre Windows 2000 login format`t: " $GatewayUsePreWin2000LoginFormat
                Line 3 "Processes that will be excluded from CPU Optimization"                                   Line 4 "Allow embedding of User Portal"
                                    Line 4 "into other web pages`t`t`t: " $GatewayAllowEmbed
                    
                If($RASCPUSettings.CPUExcludeList.Count -eq 0)                                   Line 4 "Allow file transfer command`t`t: " $GatewayAllowFileTransfer.ToString()
                                    If($Gateway.AllowFileTransfer)
                {                                   {
                        Line 4 "Processes to exclude`t`t`t: None"                                           Line 5 "Direction`t`t`t: " $GatewayFileTransferMode
                }                                   }
                Else    
                                    Line 4 "Allow clipboard command`t`t`t: " $GatewayAllowClipboard.ToString()
                                    If($Gateway.AllowClipboard)
                {                                   {
                                            Line 5 "Clipboard Redirection`t`t: " $GatewayClipboardTransferMode
                                    }
     
                                    Line 4 "Allow cross-origin resource sharing`t: " $GatewayAllowCORS.ToString()
                                    If($GatewayAllowCORS)
                                    {
                        $cnt = -1                                           $cnt=-1
                                                                  ForEach($Domain in $GatewayAllowedDomainsForCORS)
                        ForEach($item in $RASCPUSettings.CPUExcludeList)    
                        {                                           {
                                $cnt++                                                   $cnt++
                                                                                  
                                If($cnt -eq 0)                                                   If($cnt -eq 0)
                                {                                                   {
                                        Line 4 "Processes to exclude`t`t`t: " $item                                                           Line 7 "Allow domains   : " $Domain
                                }                                                   }
                                Else                                                   Else
                                {                                                   {
                                        Line 9 "  " $item                                                           Line 9 "  " $Domain
                                }                                                   }
                        }                                           }
                                            Line 6 "Browser cache time      : " "$($GatewayBrowserCacheTimeInMonths.ToString()) months"
                }                                   }
 
  <>                                 Line 3 "Network Load Balancer access" ""
                                    Line 4 "Use alternate hostname`t`t: " $GatewayEnableAlternateNLBHostname
                                    If($GatewayEnableAlternateNLBHostname -eq "True")
                                    {
                                            Line 8 $GatewayAlternameNLBHostname
                                    }
                Line 2 "Settings are replicated to all Sites`t`t`t: " $RASCPUSettings.Replicate.ToString()                                   Line 4 "Use alternate port`t`t: " $GatewayEnableAlternateNLBPort
                                    If($GatewayEnableAlternateNLBPort -eq "True")
                                    {
                                            Line 8 $GatewayAlternateNLBPort
                                    }
                Line 0 ""                                   Line 0 ""
        }                           }
        If($HTML)                           If($HTML)
        {                           {
                $rowdata = @()                                   $rowdata = @()
                $columnHeaders = @("Enable CPU Optimization",($Script:htmlsb),$RASCPUSettings.EnableCPUOptimization.ToString(),$htmlwhite)                                   $columnHeaders = @("Inherit default settings",($Script:htmlsb),$Gateway.InheritDefaultUserPortalSettings.ToString(),$htmlwhite)
                                    $rowdata += @(,("Enable User Portal",($Script:htmlsb),$GatewayEnableUserPortalClient,$htmlwhite))
                $rowdata += @(,("Start",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Client",($Script:htmlsb),"",$htmlwhite))
                $rowdata += @(,("     Total CPU usage exceeds",($Script:htmlsb),"$($RASCPUSettings.StartUsage) %",$htmlwhite))                                   $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$GatewayLaunchSessionsUsing,$htmlwhite))
                                    $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$GatewayAllowLaunchMethod,$htmlwhite))
                                    $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb),$GatewayAllowAppsInNewTab,$htmlwhite))
                $rowdata += @(,("CPU Conditions",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb),$GatewayUsePreWin2000LoginFormat,$htmlwhite))
                $rowdata += @(,("     Critical - CPU usage by process exceeds",($Script:htmlsb),"$($RASCPUSettings.CriticalUsage) %",$htmlwhite))                                   $rowdata += @(,("     Allow embedding of User Portal into other web pages",($Script:htmlsb),$GatewayAllowEmbed,$htmlwhite))
     
                $rowdata += @(,("     Idle - CPU usage by process exceeds",($Script:htmlsb),"$($RASCPUSettings.IdleUsage) %",$htmlwhite))                                   $rowdata += @(,("     Allow file transfer command",($Script:htmlsb),$GatewayAllowFileTransfer.ToString(),$htmlwhite))
                                    If($Gateway.AllowFileTransfer)
                                    {
                $rowdata += @(,("Exclusions",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("          Direction",($Script:htmlsb),$GatewayFileTransferMode,$htmlwhite))
                                    }
     
                $rowdata += @(,("     Processes that will be excluded from CPU Optimization",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Allow clipboard command",($Script:htmlsb),$GatewayAllowClipboard.ToString(),$htmlwhite))
                                                  If($Gateway.AllowClipboard)
                If($RASCPUSettings.CPUExcludeList.Count -eq 0)    
                {                                   {
                        $rowdata += @(,("          Processes to exclude",($Script:htmlsb),"None",$htmlwhite))                                           $rowdata += @(,("          Clipboard Redirection",($Script:htmlsb),$GatewayClipboardTransferMode,$htmlwhite))
                }                                   }
                Else    
                                    $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$GatewayAllowCORS.ToString(),$htmlwhite))
                                    If($GatewayAllowCORS)
                {                                   {
                        $cnt = -1                                           $cnt=-1
                                                                  ForEach($Domain in $GatewayAllowedDomainsForCORS)
                        ForEach($item in $RASCPUSettings.CPUExcludeList)    
                        {                                           {
                                $cnt++                                                   $cnt++
                                                                                  
                                If($cnt -eq 0)                                                   If($cnt -eq 0)
                                {                                                   {
                                        $rowdata += @(,("          Processes to exclude",($Script:htmlsb),$item,$htmlwhite))                                                           $rowdata += @(,("     Allow domains",($Script:htmlsb),$Domain,$htmlwhite))
                                }                                                   }
                                Else                                                   Else
                                {                                                   {
                                        $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),$Domain,$htmlwhite))
                                }                                                   }
                        }                                           }
                                            $rowdata += @(,("     Browser cache time",($Script:htmlsb),"$($GatewayBrowserCacheTimeInMonths.ToString()) months",$htmlwhite))
                }                                   }
 
  <>                                 $rowdata += @(,("Network Load Balancer access",($Script:htmlsb),"",$htmlwhite))
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASCPUSettings.Replicate.ToString(),$htmlwhite))                                   $rowdata += @(,("     Use alternate hostname",($Script:htmlsb),$GatewayEnableAlternateNLBHostname,$htmlwhite))
                $msg = ""                                   If($GatewayEnableAlternateNLBHostname -eq "True")
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }                                   {
                                            $rowdata += @(,("",($Script:htmlsb),$GatewayAlternameNLBHostname,$htmlwhite))
}                                   }
#endregion                                   $rowdata += @(,("     Use alternate port",($Script:htmlsb),$GatewayEnableAlternateNLBPort,$htmlwhite))
                                    If($GatewayEnableAlternateNLBPort -eq "True")
#region process publishing    
Function ListFolder($folder, $spaces)     
{                                   {
        #function provided 23-July-2020 by Ian Sant of Parallels                                           $rowdata += @(,("",($Script:htmlsb),$GatewayAlternateNLBPort,$htmlwhite))
        #list published items in the order they appear in the console    
        #modified 24-July-2020 by Webster to make it work with this script    
        $prevId = 0    
     
        Do    
        {    
                $item = $Script:AllItems | Where-Object {($_.ParentId -eq $folder) -and ($_.PreviousId -eq $prevId)}    
                If ($Null -eq $item) {    
                        Return    
                }                                   }
 
                #Write-Host $spaces $item.Name <>                                 $msg = "User Portal"
                $Script:OrderedItems.Add($item) >$Null                                   $columnWidths = @("300","275")
                If ($item.Type -eq "Folder") {                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                        $newspaces = $spaces + "   "                                   WriteHTMLLine 0 0 ""
                        ListFolder $item.Id $newspaces    
                }                           }
                $prevId = $item.Id    
        } While ($true)     
}    
                            #Wyse
Function ProcessPublishing    
{    
        Param([object]$Site)    
            
        Write-Verbose "$(Get-Date -Format G): Processing Publishing"    
            
        OutputPublishingSectionPage $Site.Name    
 
        Write-Verbose "$(Get-Date -Format G): `tProcessing Publishing" <>  
            
        $results = Get-RASPubItem -SiteId $Site.Id -EA 0 4>$Null    
                    
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Publishing information for Site $($Site.Name)    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Publishing information for Site $($Site.Name)"                                   WriteWordLine 4 0 "Wyse"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve Publishing information for Site $($Site.Name)"                                   Line 2 "Wyse"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Publishing information for Site $($Site.Name)"                                   #Nothing
                }                           }
        }                           
        ElseIf($? -and $null -eq $results)                           If($Gateway.InheritDefaultWyseSettings)
        {                           {
                Write-Host "                                   #do we inherit site defaults?
                No Publishing information was found for Site $($Site.Name)                                   #yes we do, get the default settings for the Site
                " -ForegroundColor White                                   #use the Site default settings
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 2 0 "No Publishing information was found for Site $($Site.Name)"                                   $GatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                }                                   
                If($Text)                                   If($? -and $Null -ne $GatewayDefaults)
                {                                   {
                        Line 0 "No Publishing information was found for Site $($Site.Name)"                                           $GatewayEnableWyse          = $GatewayDefaults.EnableWyseSupport.ToString()
                                            $GatewayDisableWyseCertWarn = $GatewayDefaults.DisableWyseCertWarn.ToString()
                }                                   }
                If($HTML)                                   Else
                {                                   {
                        WriteHTMLLine 2 0 "No Publishing information was found for Site $($Site.Name)"                                           #unable to retrieve default, use built-in default values
                                            $GatewayEnableWyse          = "True"
                                            $GatewayDisableWyseCertWarn = "False"
                }                                   }
        }                           }
        Else                           Else
        {                           {
                                    #we don't inherit settings
                                    #get the settings configured for this GW
                                    $GatewayEnableWyse          = $Gateway.EnableWyseSupport.ToString()
                $Script:OrderedItems = New-Object System.Collections.ArrayList                                   $GatewayDisableWyseCertWarn = $Gateway.DisableWyseCertWarn.ToString()
                $Script:AllItems = $results    
                ListFolder 0 ""    
                OutputPublishingSettings $Script:OrderedItems $Site.Id $Site.Name    
        }                           }
}    
     
Function OutputPublishingSectionPage    
{    
        Param([string] $SiteName)    
                                  
        If($MSWord -or $PDF)                           If($MSWord -or $PDF)
        {                           {
                $Script:Selection.InsertNewPage()                                   $ScriptInformation = New-Object System.Collections.ArrayList
                WriteWordLine 1 0 "Publishing for Site $($SiteName)"                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $Gateway.InheritDefaultWyseSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable Wyse ThinOS Support"; Value = $GatewayEnableWyse; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Do not warn if server certificate is not verified"; Value = $GatewayDisableWyseCertWarn; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
        }                           }
        If($Text)                           If($Text)
        {                           {
                Line 0 "Publishing for Site $($SiteName)"                                   Line 3 "Inherit default settings`t`t`t : " $Gateway.InheritDefaultWyseSettings.ToString()
                                    Line 3 "Enable Wyse ThinOS Support`t`t`t : " $GatewayEnableWyse
                                    Line 3 "Do not warn if server certificate is not verified: " $GatewayDisableWyseCertWarn
                                    Line 0 ""
        }                           }
        If($HTML)                           If($HTML)
        {                           {
                WriteHTMLLine 1 0 "Publishing for Site $($SiteName)"                                   $rowdata = @()
                                    $columnHeaders = @("Inherit default settings",($Script:htmlsb),$Gateway.InheritDefaultWyseSettings.ToString(),$htmlwhite)
                                    $rowdata += @(,("Enable Wyse ThinOS Support",($Script:htmlsb),$GatewayEnableWyse,$htmlwhite))
                                    $rowdata += @(,("Do not warn if server certificate is not verified",($Script:htmlsb),$GatewayDisableWyseCertWarn,$htmlwhite))
        }    
                                    $msg = "Wyse"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
}                           }
 
Function OutputPublishingSettings <>  
{    
        Param([object] $PubItems, [uint32] $SiteId, [string] $xSiteName)    
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Publishing"    
            
        <#    
        Folder    
        PCApp    
        PCDesktop    
        RDSApp    
        RDSDesktop    
        VDIApp    
        VDIDesktop    
        WVDApp    
        WVDDesktop    
        #>    
     
        #Get the published items default settings    
        Write-Verbose "$(Get-Date -Format G): `t`t`tRetrieve Publishing Default Site Settings for Site $xSiteName"    
        $results = Get-RASPubDefaultSettings -SiteId $SiteId -EA 0 4>$Null    
            
        If(!$?)    
        {    
                Write-Host "    
                Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults    
                " -ForegroundColor White    
                <#    
                StartPath                     : RAS Remote Desktops & Applications\%Groups%    
                CreateShortcutOnDesktop       : False    
                CreateShortcutInStartFolder   : True    
                CreateShortcutInStartUpFolder : False    
                ReplicateShortcutSettings     : False    
                ReplicateDisplaySettings      : False    
                WaitForPrinters               : False    
                StartMaximized                : True    
                WaitForPrintersTimeout        : 20    
                ColorDepth                    : ClientSpecified    
                DisableSessionSharing         : False    
                OneInstancePerUser            : False    
                ConCurrentLicenses            : 0    
                LicenseLimitNotify            : WarnUserAndNoStart    
                ReplicateLicenseSettings      : False    
                #>    
                    
                #Shortcuts tab                           #Security
                $DefaultCreateShortcutOnDesktop       = "False"    
                $DefaultCreateShortcutInStartFolder   = "True"    
                $DefaultStartPath                     = "RAS Remote Desktops & Applications\%Groups%"    
                $DefaultCreateShortcutInStartUpFolder = "False"    
                $DefaultReplicateShortcutSettings     = "False"    
                                          
                #License tab    
                $DefaultDisableSessionSharing         = "False"    
                $DefaultOneInstancePerUser            = "False"    
                $DefaultConCurrentLicenses            = "Unlimited"    
                $DefaultLicenseLimitNotify            = "Warn user and do not start"    
                $DefaultReplicateLicenseSettings      = "False"    
     
                #Display tab    
                $DefaultWaitForPrinters               = "False"    
                $DefaultWaitForPrintersTimeout        = "20"    
                $DefaultColorDepth                    = "Client Specified"    
                $DefaultStartMaximized                = "True"    
                $DefaultReplicateDisplaySettings      = "False"    
     
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"                                   WriteWordLine 4 0 "Security"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"                                   Line 2 "Security"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"    
                }                                   #Nothing
        }                           }
        Else    
        {                           
                #Shortcuts tab    
                $DefaultCreateShortcutOnDesktop       = $results.CreateShortcutOnDesktop.ToString()          
                $DefaultCreateShortcutInStartFolder   = $results.CreateShortcutInStartFolder.ToString()    
                $DefaultStartPath                     = $results.StartPath                                               If($Gateway.InheritDefaultSecuritySettings)
                $DefaultCreateShortcutInStartUpFolder = $results.CreateShortcutInStartUpFolder.ToString()    
                $DefaultReplicateShortcutSettings     = $results.ReplicateShortcutSettings.ToString()    
     
                #License tab    
                $DefaultDisableSessionSharing         = $results.DisableSessionSharing.ToString()        
                $DefaultOneInstancePerUser            = $results.OneInstancePerUser.ToString()    
                If($results.ConCurrentLicenses -eq 0)    
                {                           {
                        $DefaultConCurrentLicenses        = "Unlimited"                                   #do we inherit site defaults?
                                    #yes we do, get the default settings for the Site
                                    #use the Site default settings
                }    
                                    $GatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                Else                                  
                                    If($? -and $Null -ne $GatewayDefaults)
                {                                   {
                        $DefaultConCurrentLicenses        = $results.ConCurrentLicenses.ToString()                                               If($GatewayDefaults.SecurityMode -eq "AllowAllExcept")
                }    
                     
                Switch ($results.LicenseLimitNotify)    
                {                                           {
                        "WarnUserAndNoStart"            {$DefaultLicenseLimitNotify = "Warn user and do not start"; Break}                                                   $GatewayAllow = "AllowAllExcept"
                        "WarnUserAndStart"                      {$DefaultLicenseLimitNotify = "Warn user and start"; Break}                                                   $MACAddresses = @()
                        "NotifyAdminAndStart"           {$DefaultLicenseLimitNotify = "Notify administrator and start"; Break}    
                        "NotifyUserAdminAndStart"       {$DefaultLicenseLimitNotify = "Notify user, administrator and start"; Break}    
                        "NotifyUserAdminAndNoStart"     {$DefaultLicenseLimitNotify = "Notify user, administrator and do not start"; Break}    
                        Default                                         {$DefaultLicenseLimitNotify = "Unable to determine If limit is eceeded: $($results.LicenseLimitNotify)"; Break}    
                }    
                    
                $DefaultReplicateLicenseSettings      = $results.ReplicateLicenseSettings.ToString()    
     
                #Display tab    
                $DefaultWaitForPrinters               = $results.WaitForPrinters.ToString()    
                $DefaultWaitForPrintersTimeout        = $results.WaitForPrintersTimeout.ToString()    
                Switch ($results.ColorDepth)                                                   ForEach($Item in $GatewayDefaults.MACAllowExcept)
                {                                                   {
                        "Colors8Bit"            {$DefaultColorDepth = "256 Colors"; Break}                                                           $MACAddresses += $Item
                        "Colors15Bit"           {$DefaultColorDepth = "High Color (15 bit)"; Break}    
                        "Colors16Bit"           {$DefaultColorDepth = "High Color (16 bit)"; Break}    
                        "Colors24Bit"           {$DefaultColorDepth = "True Color (24 bit)"; Break}    
                        "Colors32Bit"           {$DefaultColorDepth = "Highest Quality (32 bit)"; Break}    
                        "ClientSpecified"       {$DefaultColorDepth = "Client Specified"; Break}    
                        Default                         {$DefaultColorDepth = "Unable to determine Color Depth: $($PubItem.ColorDepth)"; Break}    
                }                                                   }
                $DefaultStartMaximized                = $results.StartMaximized.ToString()       
                $DefaultReplicateDisplaySettings      = $results.ReplicateDisplaySettings.ToString()    
        }                                           }
            
        ForEach($PubItem in $PubItems)    
        {    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tOutput $($PubItem.Name)"    
                                            Else
                If(ValidObject $PubItem WinType)    
                {                                           {
                        Switch ($PubItem.WinType)                                                   $GatewayAllow = "AllowOnly"
                                                    $MACAddresses = @()
                                                    ForEach($Item in $GatewayDefaults.MACAllowOnly)
                        {                                                   {
                                "Normal"        {$WinType = "Normal Window"; Break}                                                           $MACAddresses += $Item
                                "Maximized"     {$WinType = "Maximized"; Break}    
                                "Minimized"     {$WinType = "Minimized"; Break}    
                                Default         {$WinType = "Unable to determine window Run type: $($PubItem.WinType)"; Break}    
                        }                                                   }
                }                                           }
     
                If($PubItem.PreferredRoutingEnabled)    
                {    
                        $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null    
                            
                        If(!$? -or $Null -eq $Results)    
                        {    
                                $PreferredRouting = ""    
                        }                                   }
                        Else                                   Else
                        {                                   {
                                $PreferredRouting = ""                                           #unable to retrieve default, use built-in default values
                                            $GatewayAllow = "AllowAllExcept"
                                            $MACAddresses = @()
                        }                                   }
                }                           }
                Else                           Else
                {                           {
                        $PreRouting = ""                                   #we don't inherit settings
                }                                   #get the settings configured for this GW
                                                  If($Gateway.SecurityMode -eq "AllowAllExcept")
                If($MSWord -or $PDF)    
                {                                   {
                        WriteWordLine 2 0 $PubItem.Name                                           $GatewayAllow = "AllowAllExcept"
                }                                           $MACAddresses = @()
                If($Text)                                           ForEach($Item in $Gateway.MACAllowExcept)
                {                                           {
                        Line 1 $PubItem.Name                                                   $MACAddresses += $Item
                }                                           }
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 $PubItem.Name    
                }                                   }
                                          Else
                If($PubItem.Type -eq "Folder")    
                {                                   {
                        If($MSWord -or $PDF)                                           $GatewayAllow = "AllowOnly"
                                            $MACAddresses = @()
                                            ForEach($Item in $Gateway.MACAllowOnly)
                        {                                           {
                                WriteWordLine 3 0 "Information"                                                   $MACAddresses += $Item
                        }                                           }
                        If($Text)    
                        {    
                                Line 2 "Information"    
                        }                                   }
                        If($HTML)    
                        {    
                                WriteHTMLLine 3 0 "Information"    
 
                                $ScriptInformation.Add(@{Data = "Folder"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $Gateway.InheritDefaultSecuritySettings.ToString(); }) > $Null
                                                                  If($GatewayAllow -eq "AllowAllExcept")
                                If($PubItem.AdminOnly -eq $True)    
 
                                        $ScriptInformation.Add(@{Data = "Use for administrative purposes"; Value = ""; }) > $Null <>  
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "Allow all except"; Value = ""; }) > $Null
 
  <>  
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else                                   Else
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
 
                                        $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null <>  
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Allow only"; Value = ""; }) > $Null
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null    
                                        }    
 
  +-  
 
                                ForEach($Site in $PubItem.PublishToSite) <>                                 ForEach($Item in $MACAddresses)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name +-  
                                            
 
                                                $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "MAC Address"; Value = $Item; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  <>                         }
                                WriteWordLine 3 0 "Sites"                           If($Text)
                                $ScriptInformation = New-Object System.Collections.ArrayList                           {
                                    Line 3 "Inherit default settings`t`t: " $Gateway.InheritDefaultSecuritySettings.ToString()
                                    If($GatewayAllow -eq "AllowAllExcept")
                                    {
                                            Line 3 "Allow all except"
                                    }
                                    Else
                                    {
                                            Line 3 "Allow only"
                                    }
 
                                ForEach($Site in $PubItem.PublishToSite) <>                                 ForEach($Item in $MACAddresses)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name +-  
                                            
 
  <>                                                 Line 3 "MAC Address`t`t`t`t: " $Item
                                            }
                                            Else
                                            {
                                                    Line 8 "  " $Item
                                            }
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                                $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null                                   $columnHeaders = @("Inherit default settings",($Script:htmlsb),$Gateway.InheritDefaultSecuritySettings.ToString(),$htmlwhite)
                                    If($GatewayAllow -eq "AllowAllExcept")
                                    {
                                            $rowdata += @(,("Allow all except",($Script:htmlsb),"",$htmlwhite))
                                    }
                                    Else
                                    {
                                            $rowdata += @(,("Allow only",($Script:htmlsb),"",$htmlwhite))
                                    }
                                    $cnt =-1
                                    ForEach($Item in $MACAddresses)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                                    $rowdata += @(,("MAC Address",($Script:htmlsb),$Item,$htmlwhite))
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null <>                                                 $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
 
  -+  
                                    $msg = "Security"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            #Web
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Web"
                            }
                            If($Text)
                            {
                                    Line 2 "Web"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($Gateway.InheritDefaultWebSettings)
                            {
                                    #do we inherit site defaults?
                                    #yes we do, get the default settings for the Site
                                    #use the Site default settings
     
                                    $GatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                    
                                    If($? -and $Null -ne $GatewayDefaults)
                                    {
                                            $GatewayDefaultURL = $GatewayDefaults.WebRequestsURL
                                            $GatewayWebCookie = $GatewayDefaults.WebCookie
                                    }
                                    Else
                                    {
                                            #unable to retrieve default, use built-in default values
                                            $GatewayDefaultURL = "https://%hostname%/RASHTML5Gateway"
                                            $GatewayWebCookie = "ASP.NET_SessionId"
                                    }
                            }
                            Else
                            {
                                    #we don't inherit settings
                                    #get the settings configured for this GW
                                    $GatewayDefaultURL = $Gateway.WebRequestsURL
                                    $GatewayWebCookie = $Gateway.WebCookie
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $Gateway.InheritDefaultWebSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Default URL"; Value = $GatewayDefaultURL; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Web cookie"; Value = $GatewayWebCookie; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  -+                         }
                            If($Text)
                            {
                                    Line 3 "Inherit default settings`t`t: " $Gateway.InheritDefaultWebSettings.ToString()
                                    Line 3 "Default URL`t`t`t`t: " $GatewayDefaultURL
                                    Line 3 "Web cookie`t`t`t`t: " $GatewayWebCookie
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Inherit default settings",($Script:htmlsb),$Gateway.InheritDefaultWebSettings.ToString(),$htmlwhite)
                                    $rowdata += @(,("Default URL",($Script:htmlsb),$GatewayDefaultURL,$htmlwhite))
                                    $rowdata += @(,("Web cookie",($Script:htmlsb),$GatewayWebCookie,$htmlwhite))
 
  <>                                 $msg = "Web"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
     
            $PAs = Get-RASBroker -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Connection Brokers for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $PAs)
            {
                    Write-Host "
                    No Connection Brokers retrieved for Site $($Site.Name).`
                                WriteWordLine 3 0 "Folder"                   " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Connection Brokers retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "Connection Brokers"
                    }
                    If($Text)
                    {
                            Line 1 "Connection Brokers"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "Connection Brokers"
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Connection Brokers"
                    ForEach($PA in $PAs)
                    {
                            $PAStatus = Get-RASBrokerStatus -Id $PA.Id -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    Write-Warning "
                                    `n
                                    Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)`
                                    "
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)"
                                    }
                            }
                            ElseIf($? -and $Null -eq $PAStatus)
                            {
                                    Write-Host "
                                    No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)"
                                    }
                            }
                            Else
                            {
                                    If($PA.Standby -eq $False)
                                    {
                                            $PAPriority = "Master"
                                    }
                                    Else
                                    {
                                            $PAPriority = "Standby"
                                    }
     
                                    $PAStatusAgentState = GetRASStatus $PAStatus.AgentState
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 3 0 "Connection Brokers $($PA.Server)"
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $ScriptInformation.Add(@{Data = "Folder Name"; Value = $PubItem.Name; }) > $Null                                           $ScriptInformation.Add(@{Data = "Server"; Value = $PA.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Priority"; Value = $PAPriority; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Status"; Value = $PAStatusAgentState; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Log level"; Value = $PAStatus.LogLevel; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PA.AdminLastMod; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Modified on"; Value = $PA.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created by"; Value = $PA.AdminCreate; }) > $Null
                                $ScriptInformation.Add(@{Data = "Use for administrative purposes"; Value = $PubItem.AdminOnly.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Created on"; Value = $PA.TimeCreate.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "ID"; Value = $PA.Id.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 300;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
     
                                OutputPubItemFilters $PubItem "MSWordPDF"    
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Folder`t`t`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"                                           Line 2 "Connection Brokers $($PA.Server)"
                                            Line 3 "Server`t`t`t: " $PA.Server
                                            Line 3 "Priority`t`t: " $PAPriority
                                Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description                                           Line 3 "Status`t`t`t: " $PAStatusAgentState
                                            Line 3 "Log level`t`t: " $PAStatus.LogLevel
                                Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod                                           Line 3 "Last modification by`t: " $PA.AdminLastMod
                                Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()                                           Line 3 "Modified on`t`t: " $PA.TimeLastMod.ToString()
                                Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate                                           Line 3 "Created by`t`t: " $PA.AdminCreate
                                Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()                                           Line 3 "Created on`t`t: " $PA.TimeCreate.ToString()
                                                                          Line 3 "ID`t`t`t: " $PA.Id.ToString()
                                If($PubItem.AdminOnly -eq $True)    
                                {    
                                        Line 3 "Use for administrative purposes"    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 "Own Filters"    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        Line 3 " User filtering is enabled"    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                Line 10 "  " $Item.Account    
                                        }    
 
                                If($PubItem.IPFilterEnabled) <>  
                                {    
                                        Line 3 " IP filtering is enabled"    
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        Line 3 " Client filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        Line 3 " MAC filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        Line 3 " Gateway filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 " Client device operating system filtering is enabled"    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                Line 10 "  Android"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                Line 10 "  ChromeApp"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                Line 10 "  iOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                Line 10 "  Linux"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                Line 10 "  macOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                Line 10 "  RAS Web Portal"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                Line 10 "  Windows"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                Line 10 "  Wyse"    
                                        }    
                                        Line 0 ""    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "Available in Site(s)`t`t`t`t`t: " $SiteName    
                                        }    
                                        Else    
                                        {    
                                                Line 10 $SiteName    
                                        }    
                                }    
                                Line 0 ""    
     
                                Line 2 Sites    
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "This published item will be available from the following Sites: " $SiteName    
                                        }    
                                        Else    
                                        {    
                                                Line 10 "  " $SiteName    
                                        }    
                                }    
                                    
                                Line 2 "Folder"    
                                Line 3 "Folder Name`t`t`t`t`t`t: " $PubItem.Name    
                                Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description    
                                Line 3 "Use for administrative purposest`t`t`t: " $PubItem.AdminOnly.ToString()    
                                Line 0 ""    
                                    
                                OutputPubItemFilters $PubItem "Text"    
                        }    
                        If($HTML)                                   If($HTML)
                        {                                   {
                                            WriteHTMLLine 3 0 "Connection Brokers $($PA.Server)"
                                $rowdata = @()                                           $rowdata = @()
     
                                $columnHeaders = @("Folder",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)                                           $columnHeaders = @("Server",($Script:htmlsb),$PA.Server,$htmlwhite)
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))                                           $rowdata += @(,("Priority",($Script:htmlsb),$PAPriority,$htmlwhite))
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))                                           $rowdata += @(,("Status",($Script:htmlsb),$PAStatusAgentState,$htmlwhite))
                                $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))    
                                    
                                If($PubItem.AdminOnly -eq $True)    
                                {    
                                        $rowdata += @(,("Use for administrative purposes",($Script:htmlsb), "",$htmlwhite))    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))                                           $rowdata += @(,("Log level",($Script:htmlsb),$PAStatus.LogLevel,$htmlwhite))
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))                                           $rowdata += @(,("Last modification by",($Script:htmlsb), $PA.AdminLastMod,$htmlwhite))
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Modified on",($Script:htmlsb), $PA.TimeLastMod.ToString(),$htmlwhite))
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))                                           $rowdata += @(,("Created by",($Script:htmlsb), $PA.AdminCreate,$htmlwhite))
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Created on",($Script:htmlsb), $PA.TimeCreate.ToString(),$htmlwhite))
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))                                           $rowdata += @(,("ID",($Script:htmlsb),$PA.Id.ToString(),$htmlwhite))
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))    
                                        }    
                                }    
 
                                $cnt =-1 <>  
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
     
                                $msg = ""                                           $msg = ""
                                $columnWidths = @("200","300")                                           $columnWidths = @("200","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
     
                                WriteHTMLLine 3 0 "Folder"    
                                $rowdata = @()    
     
                                $columnHeaders = @("Folder",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Use for administrative purposes",($Script:htmlsb),$PubItem.AdminOnly.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                OutputPubItemFilters $PubItem "HTML"    
                        }                                   }
                }                           }
                ElseIf($PubItem.Type -eq "PCApp")    
                {                           
 
                                WriteWordLine 3 0 "Information" <>                                 WriteWordLine 4 0 "Properties"
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Remote PC Application"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null    
     
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null    
                                }                           }
                                    
                                $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null    
                                    
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
                            If($Text)
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {                           {
                                        $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null                                   Line 2 "Properties"
                                }                           }
                            If($HTML)
                                If($PubItem.UserFilterEnabled)    
                                {                           {
                                        $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null    
                                    #Nothing
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }                           }
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null    
                                                                  
                                        ForEach($item in $PubItem.AllowedClients)                           If($MSWord -or $PDF)
                                        {                           {
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable Server in Site"; Value = $PA.Enabled.ToString(); }) > $Null
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                   $ScriptInformation.Add(@{Data = "Server"; Value = $PA.Server; }) > $Null
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                   $ScriptInformation.Add(@{Data = "IP"; Value = $PA.IP; }) > $Null
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Alternative IPs"; Value = $PA.AlternativeIPs; }) > $Null
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $PA.Description; }) > $Null
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null                                   $ScriptInformation.Add(@{Data = "Standby"; Value = $PA.Standby.ToString(); }) > $Null
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null    
                                        }    
                                }    
 
                                $cnt =-1 +-  
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null    
                                        }    
                                }    
 
  <>                                 $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Enable Server in Site`t: " $PA.Enabled.ToString()
                                    Line 3 "Server`t`t`t: " $PA.Server
                                    Line 3 "IP`t`t`t: " $PA.IP
                                    Line 3 "Alternative IPs`t`t: " $PA.AlternativeIPs
                                    Line 3 "Description`t`t: " $PA.Description
                                    Line 3 "Standby`t`t`t: " $PA.Standby.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Enable Server in Site",($Script:htmlsb),$PA.Enabled.ToString(),$htmlwhite)
                                    $rowdata += @(,("Server",($Script:htmlsb),$PA.Server,$htmlwhite))
                                    $rowdata += @(,("IP",($Script:htmlsb),$PA.IP,$htmlwhite))
                                    $rowdata += @(,("Alternative IPs",($Script:htmlsb),$PA.AlternativeIPs,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$PA.Description,$htmlwhite))
                                    $rowdata += @(,("Standby",($Script:htmlsb),$PA.Standby.ToString(),$htmlwhite))
     
                                    $msg = "Properties"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
            
            #Enrollment Servers - not in PoSH
            
            #HALB
            $HALBs = Get-RASHALB -Siteid $Site.Id -EA 0 4> $Null 
     
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve HALBs for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve HALBs for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $HALBs)
            {
                    Write-Host "
            No HALBs retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No HALBs retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No HALBs retrieved for Site $($Site.Name)"
                            Line 0 ""
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No HALBs retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "HALB"
                    }
                    If($Text)
                    {
                            Line 1 "HALB"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "HALB"
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput HALB"
                    ForEach($HALB in $HALBs)
                    {
                            $HALBStatusResult = Get-RASHALBStatus -Name $HALB.Name -EA 0 4> $Null 
                            
                            If($? -and $Null -ne $HALBStatusResult)
                            {
                                    $HALBStatus = GetRASStatus $HALBStatusResult.AgentState
                            }
                            Else
                            {
                                    $HALBStatus = "Unable to determine HALB status"
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "HALB $($HALB.Name)"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "IPv4"; Value = $HALB.VirtualIPV4; }) > $Null
                                    $ScriptInformation.Add(@{Data = "IPv6"; Value = $HALB.VirtualIPV6; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Status"; Value = $HALBStatus; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Public Address"; Value = $HALB.PublicAddress; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $HALB.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $HALB.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $HALB.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $HALB.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "ID"; Value = $HALB.Id.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                $Table.Columns.Item(2).Width = 300;                                   $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
 
  -+                         }
                            If($Text)
                            {
                                    Line 2 "HALB $($HALB.Name)"
                                    Line 3 "Name`t`t`t: " $HALB.Name
                                    Line 3 "IPv4`t`t`t: " $HALB.VirtualIPV4
                                    Line 3 "IPv6`t`t`t: " $HALB.VirtualIPV6
                                    Line 3 "Status`t`t`t: " $HALBStatus
                                    Line 3 "Description`t`t: " $HALB.Description
                                    Line 3 "Public Address`t`t: " $HALB.PublicAddress
                                    Line 3 "Last modification by`t: " $HALB.AdminLastMod
                                    Line 3 "Modified on`t`t: " $HALB.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t: " $HALB.AdminCreate
                                    Line 3 "Created on`t`t: " $HALB.TimeCreate.ToString()
                                    Line 3 "ID`t`t`t: " $HALB.Id.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 3 0 "HALB $($HALB.Name)"
                                    $rowdata = @()
                                    $columnHeaders = @("Name",($Script:htmlsb),$HALB.Name,$htmlwhite)
                                    $rowdata += @(,("IPv4",($Script:htmlsb),$HALB.VirtualIPV4,$htmlwhite))
                                    $rowdata += @(,("IPv6",($Script:htmlsb),$HALB.VirtualIPV6,$htmlwhite))
                                    $rowdata += @(,("Status",($Script:htmlsb),$HALBStatus,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))
                                    $rowdata += @(,("Public Address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $HALB.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $HALB.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $HALB.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $HALB.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("ID",($Script:htmlsb),$HALB.Id.ToString(),$htmlwhite))
 
  <>                                 $msg = ""
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "General"
                            }
                            If($Text)
                            {
                                    Line 2 "General"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            Switch($HALB.IPVersion)
                            {
                                    "Version4"              {$HALBIPVersion = "Version 4"; Break}
                                    "Version6"              {$HALBIPVersion = "Version 6"; Break}
                                    "BothVersions"  {$HALBIPVersion = "Both version 4 & 6"; Break}
                                    Default                 {$HALBIPVersion = "Unable to determine IP version: $($HALB.IPVersion)"; Break}
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Enable HALB"; Value = $HALB.EnableHALBInstance.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Public address"; Value = $HALB.PublicAddress; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Virtual IP"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Use IP version"; Value = $HALBIPVersion; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     IPv4"; Value = $HALB.VirtualIPV4; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Subnet Mask"; Value = $HALB.SubNetMask; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     IPv6"; Value = $HALB.VirtualIPV6; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Prefix"; Value = $HALB.PrefixIPV6; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     LB Gateway Payload"; Value = $HALB.EnableGWPayload.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "     LB SSL Payload"; Value = $HALB.EnableSSLPayload.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Device Management"; Value = $HALB.EnableDeviceManagement.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                WriteWordLine 3 0 "Sites"                                   WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Enable HALB`t`t`t: " $HALB.EnableHALBInstance.ToString()
                                    Line 3 "Name`t`t`t`t: " $HALB.Name
                                    Line 3 "Description`t`t`t: " $HALB.Description
                                    Line 3 "Public address`t`t`t: " $HALB.PublicAddress
                                    Line 3 "Virtual IP"
                                    Line 4 "Use IP version`t`t: " $HALBIPVersion
                                    Line 4 "IPv4`t`t`t: " $HALB.VirtualIPV4
                                    Line 4 "Subnet Mask`t`t: " $HALB.SubNetMask
                                    Line 4 "IPv6`t`t`t: " $HALB.VirtualIPV6
                                    Line 4 "Prefix`t`t`t: " $HALB.PrefixIPV6
                                    Line 3 "Settings"
                                    Line 4 "LB Gateway Payload`t: " $HALB.EnableGWPayload.ToString()
                                    Line 4 "LB SSL Payload`t`t: " $HALB.EnableSSLPayload.ToString()
                                    Line 4 "Device Management`t: " $HALB.EnableDeviceManagement.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Enable HALB",($Script:htmlsb),$HALB.EnableHALBInstance.ToString(),$htmlwhite)
                                    $rowdata += @(,("Name",($Script:htmlsb),$HALB.Name,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))
                                    $rowdata += @(,("Public address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))
                                    $rowdata += @(,("Virtual IP",($Script:htmlsb), "",$htmlwhite))
                                    $rowdata += @(,("     Use IP version",($Script:htmlsb), $HALBIPVersion,$htmlwhite))
                                    $rowdata += @(,("     IPv4",($Script:htmlsb), $HALB.VirtualIPV4,$htmlwhite))
                                    $rowdata += @(,("     Subnet Mask",($Script:htmlsb), $HALB.SubNetMask,$htmlwhite))
                                    $rowdata += @(,("     IPv6",($Script:htmlsb), $HALB.VirtualIPV6,$htmlwhite))
                                    $rowdata += @(,("     Prefix",($Script:htmlsb), $HALB.PrefixIPV6,$htmlwhite))
                                    $rowdata += @(,("Settings",($Script:htmlsb), "",$htmlwhite))
                                    $rowdata += @(,("     LB Gateway Payload",($Script:htmlsb), $HALB.EnableGWPayload.ToString(),$htmlwhite))
                                    $rowdata += @(,("     LB SSL Payload",($Script:htmlsb), $HALB.EnableSSLPayload.ToString(),$htmlwhite))
                                    $rowdata += @(,("     Device Management",($Script:htmlsb), $HALB.EnableDeviceManagement.ToString(),$htmlwhite))
     
                                    $msg = "General"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "LB gateway payload"
                            }
                            If($Text)
                            {
                                    Line 2 "LB gateway payload"
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 4 0 "LB gateway payload"
                            }
                            
                            $HALBGatewayPort = $HALB.GatewayConfig.Port.ToString()
                            $HALBGateways    = $HALB.GatewayConfig.Gateways
                            
                            #First, get the port
                            If($MSWord -or $PDF)
                            {
 
  -+                                 $ScriptInformation.Add(@{Data = "Port"; Value = $HALBGatewayPort; }) > $Null
 
  <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                $cnt =-1                                   -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Port: " $HALBGatewayPort
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Port",($Script:htmlsb),$HALBGatewayPort,$htmlwhite)
                                    #$rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            #second, process the gateways
                            #do output headers
                            If($MSWord -or $PDF)
                            {
                                    [System.Collections.Hashtable[]] $GatewaysWordTable = @();
                            }
                            If($Text)
                            {
                                    Line 3 "Gateways                                                 Status                                  "
                                    Line 3 "================================================================================================="
                                    #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890
                                    #       1234567890123456789012345678901234567890123456789012345
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                            }
                            
                            #process the gateways data
                            ForEach($GatewayItem in $HALBGateways)
                            {
                                    $ip = $GatewayItem.Keys
                                    $Results = [System.Net.Dns]::gethostentry($ip)
                                    $hostname = $Results.HostName
                                    $TempGW = Get-RASGatewayStatus -Server $hostname -EA 0 4> $Null
                                    $HALBGWStatus = GetRASStatus $TempGW.AgentState
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            $GatewaysWordTableRowHash = @{
                                                    Gateway       = "$hostname ($ip)";
                                                    GatewayStatus = $HALBGWStatus;
                                            }
                                            $GatewaysWordTable += $GatewaysWordTableRowHash
                                    }
                                    If($Text)
                                    {
                                            Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            "$hostname ($ip)",$htmlwhite,
                                            $HALBGWStatus,$htmlwhite))
                                    }
                            }
                            
                            #output the Word/PDF and HTML tables
                            If($MSWord -or $PDF)
                            {
                                    If($GatewaysWordTable.Count -gt 0)
                                    {
                                            $Table = AddWordTable -Hashtable $GatewaysWordTable `
                                            -Columns  Gateway,GatewayStatus `
                                            -Headers  "Gateways","Status"`
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                            }
                            If($Text)
                            {
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $columnHeaders = @(
                                    "Gateways",($Script:htmlsb),
                                    "Status",($Script:htmlsb))
     
                                    $msg = ""
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "LB SSL payload"
                            }
                            If($Text)
                            {
                                    Line 2 "LB SSL payload"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            $HALBSSLGatewayPort = $HALB.SSLConfig.GatewayConfig.Port.ToString()
                            $HALBSSLGateways    = $HALB.SSLConfig.GatewayConfig.Gateways
                            
                            Switch($HALB.SSLConfig.SSLMode)
                            {
                                    "SSLOffloading"         {$HALBSSLMode = "SSL Offloading"; Break}
                                    "SSLPassthrough"        {$HALBSSLMode = "Passthrough"; Break}
                                    Default                         {$HALBSSLMode = "Unable to etermine SSL Mode: $($HALB.SSLConfig.SSLMode)"; Break}
                            }
                            
                            If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                            {
                                    Switch($HALB.SSLConfig.MinSSLVersion)
                                    {
                                            "SSLv2"         {$HALBSSLAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}
                                            "SSLv3"         {$HALBSSLAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}
                                            "TLSv1"         {$HALBSSLAcceptedSSLVersions = "TLS v1.0 - TLS v1.2"; Break}
                                            "TLSv1_1"       {$HALBSSLAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}
                                            "TLSv1_2"       {$HALBSSLAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}
                                            Default         {$HALBSSLAcceptedSSLVersions = "Unable to determine Minimum SSL version: $($HALB.SSLConfig.MinSSLVersion)"; Break}
                                    }
                                    
                                    If($HALB.SSLConfig.SSLCipherStrength -eq "Custom")
                                    {
                                            $HALBSSLCipherStrength = "Custom"
                                            $HALBSSLCipher         = $HALB.SSLConfig.SSLCustomCipher
                                    }
                                    Else
                                    {
                                            $HALBSSLCipherStrength = $HALB.SSLConfig.SSLCipherStrength
                                            Switch($HALB.SSLConfig.SSLCipherStrength)
                                            {
                                                    "Low"           {$HALBSSLCipher = "All:!aNULL:!eNULL"; Break}
                                                    "Medium"        {$HALBSSLCipher = "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"; Break}
                                                    "High"          {$HALBSSLCipher = "EECDH:!SSLv2:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"; Break}
                                                    Default         {$HALBSSLCipher = "Unable to determine SSL cipher strength: $($HALB.SSLConfig.SSLCipherStrength)"; Break}
                                            }
                                    }
                                    $HALBSSLUseServerPreference = $HALB.SSLConfig.SSLCipherPreference.ToString()
                                    If($HALB.SSLConfig.CertID -eq 0)
                                    {
                                            $HALBSSLCertificates = "All matching usage"
                                    }
                                    Else
                                    {
                                            $Results = Get-RASCertificate -Id $HALB.SSLConfig.CertID -EA 0 4> $Null
                                            
                                            If($? -and $Null -ne $Results)
                                            {
                                                    $HALBSSLCertificates = $Results.Name
                                            }
                                            Else
                                            {
                                                    $HALBSSLCertificates = "Unable to find certificate with an ID of $($HALB.SSLConfig.CertID)"
                                            }
                                    }
                            }
                            Else
                            {
                                    $HALBSSLAcceptedSSLVersions = ""
                                    $HALBSSLCipherStrength      = ""
                                    $HALBSSLCipher              = ""
                                    $HALBSSLUseServerPreference = ""
                                    $HALBSSLCertificates        = ""
                            }
                            
                            #First, get the port
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Port"; Value = $HALBSSLGatewayPort; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Mode"; Value = $HALBSSLMode; }) > $Null
                                    If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                                    {
                                            $ScriptInformation.Add(@{Data = "Security"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Accepted SSL Versions"; Value = $HALBSSLAcceptedSSLVersions; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Cipher Strength"; Value = $HALBSSLCipherStrength; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Cipher"; Value = $HALBSSLCipher; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Use ciphers according to server preference"; Value = $HALBSSLUseServerPreference; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Certificates"; Value = $HALBSSLCertificates; }) > $Null
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Port: " $HALBSSLGatewayPort
                                    Line 3 "Mode: " $HALBSSLMode
                                    If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                                    {
                                            Line 3 "Security"
                                            Line 4 "Accepted SSL Versions`t`t`t`t: " $HALBSSLAcceptedSSLVersions
                                            Line 4 "Cipher Strength`t`t`t`t`t: " $HALBSSLCipherStrength
                                            Line 4 "Cipher`t`t`t`t`t`t: " $HALBSSLCipher
                                            Line 4 "Use ciphers according to server preference`t: " $HALBSSLUseServerPreference
                                            Line 4 "Certificates`t`t`t`t`t: " $HALBSSLCertificates
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Port",($Script:htmlsb),$HALBSSLGatewayPort,$htmlwhite)
                                    $rowdata += @(,("Mode",($Script:htmlsb),$HALBSSLMode,$htmlwhite))
                                    If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                                    {
                                            $rowdata += @(,( "Security",($Script:htmlsb), "",$htmlwhite))
                                            $rowdata += @(,( "     Accepted SSL Versions",($Script:htmlsb), $HALBSSLAcceptedSSLVersions,$htmlwhite))
                                            $rowdata += @(,( "     Cipher Strength",($Script:htmlsb), $HALBSSLCipherStrength,$htmlwhite))
                                            $rowdata += @(,( "     Cipher",($Script:htmlsb), $HALBSSLCipher,$htmlwhite))
                                            $rowdata += @(,( "     Use ciphers according to server preference",($Script:htmlsb), $HALBSSLUseServerPreference,$htmlwhite))
                                            $rowdata += @(,( "     Certificates",($Script:htmlsb), $HALBSSLCertificates,$htmlwhite))
                                    }
     
                                    $msg = ""
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            #second, process the gateways
                            #do output headers
                            If($MSWord -or $PDF)
                            {
                                    [System.Collections.Hashtable[]] $GatewaysWordTable = @();
                            }
                            If($Text)
                            {
                                    Line 3 "Gateways                                                 Status                                  "
                                    Line 3 "================================================================================================="
                                    #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890
                                    #       1234567890123456789012345678901234567890123456789012345
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                            }
                            
                            #process the gateways data
                                ForEach($Site in $PubItem.PublishToSite)                           ForEach($GatewayItem in $HALBSSLGateways)
                            {
                                    $ip = $GatewayItem.Keys
                                    $Results = [System.Net.Dns]::gethostentry($ip)
                                    $hostname = $Results.HostName
                                    $TempGW = Get-RASGatewayStatus -Server $hostname -EA 0 4> $Null
                                    $HALBGWStatus = GetRASStatus $TempGW.AgentState
                                    
                                    If($MSWord -or $PDF)
 
  <>                                         $GatewaysWordTableRowHash = @{
                                                    Gateway       = "$hostname ($ip)";
                                                    GatewayStatus = $HALBGWStatus;
                                            }
                                            $GatewaysWordTable += $GatewaysWordTableRowHash
                                    }
                                    If($Text)
                                    {
                                            Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            "$hostname ($ip)",$htmlwhite,
                                            $HALBGWStatus,$htmlwhite))
                                    }
                            }
                            
                            #output the Word/PDF and HTML tables
                            If($MSWord -or $PDF)
                            {
                                    If($GatewaysWordTable.Count -gt 0)
                                    {
                                            $Table = AddWordTable -Hashtable $GatewaysWordTable `
                                            -Columns  Gateway,GatewayStatus `
                                            -Headers  "Gateways","Status"`
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
                                        $cnt++    
                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                            }
                            If($Text)
                            {
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $columnHeaders = @(
                                    "Gateways",($Script:htmlsb),
                                    "Status",($Script:htmlsb))
     
                                    $msg = ""
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"
                                    WriteHTMLLine 0 0 ""
                            }
    <#
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Device Manager"
                            }
                            If($Text)
                            {
                                    Line 2 "Device Manager"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Port"; Value = ""; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Port: "
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Port",($Script:htmlsb),"",$htmlwhite)
                                    $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
     
                                    $msg = "Device Manager"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
    #>
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Devices"
                            }
                            If($Text)
                            {
                                    Line 2 "Devices"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name                           $HALBDevices = Get-RASHALBDevice -HALBName $HALB.Name -EA 0 4> $Null
                            
                            If((!$?) -or ($? -and $Null -eq $HALBDevices))
                            {
                                    Write-Host "
                                    No HALB Devices retrieved for HALB $($HALB.Name).`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No HALB Devices retrieved for HALB $($HALB.Name)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"
                                    }
                            }
                            Else
                            {
                                    If($MSWord -or $PDF)
                                    {
                                            [System.Collections.Hashtable[]] $HALBDevicesWordTable = @();
                                    }
                                    If($Text)
                                    {
                                            Line 3 "Devices          ID"
                                            Line 3 "==================="
                                            #       999.999.999.999SS12
                                    }
                                    If($HTML)
                                    {
                                            $rowdata = @()
                                    }
                                    
                                    #process the gateways data
                                    ForEach($HALBDevice in $HALBDevices)
                                    {
                                            $ip = $HALBDevice.DeviceIP
                                            $ID = $HALBDevice.DeviceId
 
  <>                                         If($MSWord -or $PDF)
                                            {
                                                    $HALBDevicesWordTableRowHash = @{
                                                            DeviceIP = $ip;
                                                            DeviceID = $ID;
                                                    }
                                                    $HALBDevicesWordTable += $HALBDevicesWordTableRowHash
                                            }
                                        If($cnt -eq 0)                                           If($Text)
 
  <>                                                 Line 3 ( "{0,-15}  {1,-2}" -f $ip, $ID)
                                            }
                                            If($HTML)
                                            {
                                                    $rowdata += @(,(
                                                    $ip,$htmlwhite,
                                                    $ID,$htmlwhite))
                                            }
                                    }
                                    
                                    #output the Word/PDF and HTML tables
                                    If($MSWord -or $PDF)
                                    {
                                            If($HALBDevicesWordTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $HALBDevicesWordTable `
                                                    -Columns  DeviceIP,DeviceID `
                                                    -Headers  "Devices","ID" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 100;
                                                    $Table.Columns.Item(2).Width = 50;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    If($Text)
                                    {
                                            Line 0 ""
                                    }
                                    If($HTML)
                                    {
                                            $columnHeaders = @(
                                            "Devices",($Script:htmlsb),
                                            "ID",($Script:htmlsb))
     
                                            $msg = ""
                                            $columnWidths = @("100","50")
                                            FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "150"
                                            WriteHTMLLine 0 0 ""
                                    }
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Advanced"
                            }
                            If($Text)
                            {
                                    Line 2 "Advanced"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Enable RDP UPD tunneling"; Value = $HALB.EnableUDPTunneling.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Maximum TCP connections"; Value = $HALB.MaxTCPConnections.ToString(); }) > $Null
                                                $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Client inactivity timeout (s)"; Value = $HALB.ClientIdleTimeout.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Gateway connection timeout (s)"; Value = $HALB.GWConnectionTimeout.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Client connection queue timeout (s)"; Value = $HALB.ClientQueueTimeout.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Gateway inactivity timeout (s)"; Value = $HALB.GatewayIdleTimeout.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Amount of TCP connections per second"; Value = $HALB.SessionsRate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Gateways health check intervals (s)"; Value = $HALB.GWHealthCheckInterval.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP virtual router ID"; Value = $HALB.VirtualRouterID.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP authentication password"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP broadcast interval (m)"; Value = $HALB.VrrpBroadcastInterval.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP health check script interval (s)"; Value = $HALB.VrrpHealthCheckInterval.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP health check script timeout"; Value = $HALB.VrrpHealthCheckTimeout.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP advertisement interval (s)"; Value = $HALB.VrrpAdvertInterval.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable OS updates"; Value = $HALB.OSUpdate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Keep existing load balancing settings"; Value = $HALB.KeepLBProxyConfig.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Keep existing VRRP/keepalive settings"; Value = $HALB.KeepVRRPConfig.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                                        }                           }
                            If($Text)
                            {
                                    Line 3 "Enable RDP UPD tunneling`t`t: " $HALB.EnableUDPTunneling.ToString()
                                    Line 3 "Maximum TCP connections`t`t`t: " $HALB.MaxTCPConnections.ToString()
                                    Line 3 "Client inactivity timeout (s)`t`t: " $HALB.ClientIdleTimeout.ToString()
                                    Line 3 "Gateway connection timeout (s)`t`t: " $HALB.GWConnectionTimeout.ToString()
                                    Line 3 "Client connection queue timeout (s)`t: " $HALB.ClientQueueTimeout.ToString()
                                    Line 3 "Gateway inactivity timeout (s)`t`t: " $HALB.GatewayIdleTimeout.ToString()
                                    Line 3 "Amount of TCP connections per second`t: " $HALB.SessionsRate.ToString()
                                    Line 3 "Gateways health check intervals (s)`t: " $HALB.GWHealthCheckInterval.ToString()
                                    Line 3 "VRRP virtual router ID`t`t`t: " $HALB.VirtualRouterID.ToString()
                                    Line 3 "VRRP authentication password`t`t: " 
                                    Line 3 "VRRP broadcast interval (m)`t`t: " $HALB.VrrpBroadcastInterval.ToString()
                                    Line 3 "VRRP health check script interval (s)`t: " $HALB.VrrpHealthCheckInterval.ToString()
                                    Line 3 "VRRP health check script timeout`t: " $HALB.VrrpHealthCheckTimeout.ToString()
                                    Line 3 "VRRP advertisement interval (s)`t`t: " $HALB.VrrpAdvertInterval.ToString()
                                    Line 3 "Enable OS updates`t`t`t: " $HALB.OSUpdate.ToString()
                                    Line 3 "Keep existing load balancing settings`t: " $HALB.KeepLBProxyConfig.ToString()
                                    Line 3 "Keep existing VRRP/keepalive settings`t: " $HALB.KeepVRRPConfig.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Enable RDP UPD tunneling",($Script:htmlsb),$HALB.EnableUDPTunneling.ToString(),$htmlwhite)
                                    $rowdata += @(,("Maximum TCP connections",($Script:htmlsb),$HALB.MaxTCPConnections.ToString(),$htmlwhite))
                                    $rowdata += @(,("Client inactivity timeout (s)",($Script:htmlsb),$HALB.ClientIdleTimeout.ToString(),$htmlwhite))
                                    $rowdata += @(,("Gateway connection timeout (s)",($Script:htmlsb),$HALB.GWConnectionTimeout.ToString(),$htmlwhite))
                                    $rowdata += @(,("Client connection queue timeout (s)",($Script:htmlsb),$HALB.ClientQueueTimeout.ToString(),$htmlwhite))
                                    $rowdata += @(,("Gateway inactivity timeout (s)",($Script:htmlsb),$HALB.GatewayIdleTimeout.ToString(),$htmlwhite))
                                    $rowdata += @(,("Amount of TCP connections per second",($Script:htmlsb),$HALB.SessionsRate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Gateways health check intervals (s)",($Script:htmlsb),$HALB.GWHealthCheckInterval.ToString(),$htmlwhite))
                                    $rowdata += @(,("VRRP virtual router ID",($Script:htmlsb),$HALB.VirtualRouterID.ToString(),$htmlwhite))
                                    $rowdata += @(,("VRRP authentication password",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("VRRP broadcast interval (m)",($Script:htmlsb),$HALB.VrrpBroadcastInterval.ToString(),$htmlwhite))
                                    $rowdata += @(,("VRRP health check script interval (s)",($Script:htmlsb),$HALB.VrrpHealthCheckInterval.ToString(),$htmlwhite))
                                    $rowdata += @(,("VRRP health check script timeout",($Script:htmlsb),$HALB.VrrpHealthCheckTimeout.ToString(),$htmlwhite))
                                    $rowdata += @(,("VRRP advertisement interval (s)",($Script:htmlsb),$HALB.VrrpAdvertInterval.ToString(),$htmlwhite))
                                    $rowdata += @(,("Enable OS updates",($Script:htmlsb),$HALB.OSUpdate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Keep existing load balancing settings",($Script:htmlsb),$HALB.KeepLBProxyConfig.ToString(),$htmlwhite))
                                    $rowdata += @(,("Keep existing VRRP/keepalive settings",($Script:htmlsb),$HALB.KeepVRRPConfig.ToString(),$htmlwhite))
     
                                    $msg = "Advanced"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
            
            #Themes
            $Themes = Get-RASTheme -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Themes for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Themes for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Themes for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Themes for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $Themes)
            {
                    Write-Host "
                    No Themes retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Themes retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Themes retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Themes retrieved for Site $($Site.Name)"
                    }
            }
                                        Else           Else
                                        {           {
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "Themes"
                    }
                    If($Text)
                    {
                            Line 1 "Themes"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "Themes"
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Themes"
                    ForEach($Theme in $Themes)
                    {
                            $ThemePostLogonMessage        = $Theme.PostLogonMessage.Split("`n")
                            $ThemeUserPortalPrelogonMessage    = $Theme.UserPortal.Message.PreLogonMessage.Split("`n")
                            $ThemeUserPortalPostlogonMessage   = $Theme.UserPortal.Message.UserPortalPostLogonMessage.Split("`n")
                            $ThemeWindowsPostlogonMessage = $Theme.WindowsClient.Messages.WindowsClientPostLogonMessage.Split("`n")
                            $ThemeUserPortalURL                = "https://FQDN/$($Theme.UserPortal.Url.LoginPageURLPath)"
                            $ThemeShowDownloadURL         = $Theme.UserPortal.Url.ShowDownloadURL.ToString()
                            $ThemeOverrideDownloadURL     = $Theme.UserPortal.Url.OverrideWindowsClientDownloadURL
                            $ThemeFooterURLs              = @(Get-RASThemeFooterURL -Name $Theme.Name -EA 0) 4> $Null #fixed in 2.52 thanks to Thomas Krampe
                            
                            If(!$? -or $Null -eq $ThemeFooterURLs)
                            {
                                    $ThemeFooterURLs = @()
                            }
                            
                            #the Get-RASThemeImage cmdlet returns all four items as an array, but there is nothing that
                            #specifies which array element is which branding image file
                            #I get each image file separately to make sure each image file is correctly associated
                            $ThemeCompanyLogo = Get-RASThemeImage -Name $Theme.name -ImageType CompanyLogo -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    $ThemeCompanyLogo = ""
                            }
                            
                            
                            $ThemeFaviconIcon = Get-RASThemeImage -Name $Theme.name -ImageType FaviconIcon -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    $ThemeFaviconIcon = ""
                            }
     
                            
                            $ThemeConnectionBanner = Get-RASThemeImage -Name $Theme.name -ImageType ConnectionBanner -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    $ThemeConnectionBanner = ""
                            }
     
                            
                            $ThemeApplicationIcon = Get-RASThemeImage -Name $Theme.name -ImageType ApplicationIcon -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    $ThemeApplicationIcon = ""
                            }
                            
                            $ThemeUserPortalLaunchSessionsUsing = ""
                            Switch($Theme.UserPortal.Gateway.LaunchMethod)
                            {
                                    "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"  
                                    {
                                            $ThemeUserPortalLaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break
                                    }
                                    "Launch_Applications_with_Parallels_Client"                                             
                                    {
                                            $ThemeUserPortalLaunchSessionsUsing = "Launch apps with Parallels Client"; Break
                                    }
                                    "Launch_Applications_with_Browser_HTML5"                                                
                                    {
                                            $ThemeUserPortalLaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break
                                    }
                                    Default                                                                                                                 
                                    {
                                            $ThemeUserPortalLaunchSessionsUsing = "Unable to determine Launch sessions using: $($Theme.UserPortal.Gateway.LaunchMethod)"; Break
                                    }
                            }
                            
                            $ThemeHTMLFileTransfer = ""
                            Switch($Theme.UserPortal.Gateway.FileTransferMode)
                            {
                                    "Disabled"                      {$ThemeHTMLFileTransfer = "Disabled"; Break}
                                    "ClientToServer"        {$ThemeHTMLFileTransfer = "Client to server only"; Break}
                                    "ServerToClient"        {$ThemeHTMLFileTransfer = "Server to client only"; Break}
                                    "Bidirectional"         {$ThemeHTMLFileTransfer = "Bidirectional"; Break}
                                    Default                         {$ThemeHTMLFileTransfer = "Unable to determine File transfer mode: $($Theme.UserPortal.Gateway.FileTransferMode)"; Break}
                            }
                            
                            $ThemeHTMLClipboardDirection = ""
                            Switch($Theme.UserPortal.Gateway.ClipboardDirection)
                            {
                                    "None"                          {$ThemeHTMLClipboardDirection = "None"; Break}
                                    "ClientToServer"        {$ThemeHTMLClipboardDirection = "Client to server only"; Break}
                                    "ServerToClient"        {$ThemeHTMLClipboardDirection = "Server to client only"; Break}
                                    "Bidirectional"         {$ThemeHTMLClipboardDirection = "Bidirectional"; Break}
                                    Default                         {$ThemeHTMLClipboardDirection = "Unable to determine Clipboard direction: $($Theme.UserPortal.Gateway.ClipboardDirection)"; Break}
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Theme $($Theme.Name)"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Name"; Value = $Theme.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $Theme.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "HTML5 URL"; Value = $ThemeUserPortalURL; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Theme.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $Theme.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $Theme.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $Theme.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "ID"; Value = $Theme.Id.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 2 "Theme $($Theme.Name)"
                                    Line 3 "Name`t`t`t: " $Theme.Name
                                    Line 3 "Description`t`t: " $Theme.Description
                                    Line 3 "HTML5 URL`t`t: " $ThemeUserPortalURL
                                    Line 3 "Last modification by`t: " $Theme.AdminLastMod
                                    Line 3 "Modified on`t`t: " $Theme.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t: " $Theme.AdminCreate
                                    Line 3 "Created on`t`t: " $Theme.TimeCreate.ToString()
                                    Line 3 "ID`t`t`t: " $Theme.Id.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $ThemeName = $Theme.Name.Replace("<","").Replace(">","")
                                    WriteHTMLLine 3 0 "Theme $ThemeName"
                                    $rowdata = @()
                                    $columnHeaders = @("Name",($Script:htmlsb),$ThemeName,$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$Theme.Description,$htmlwhite))
                                    $rowdata += @(,("HTML5 URL",($Script:htmlsb),$ThemeUserPortalURL,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $Theme.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $Theme.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $Theme.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $Theme.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("ID",($Script:htmlsb),$Theme.Id.ToString(),$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "General"
                            }
                            If($Text)
                            {
                                    Line 2 "General"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Enable Theme"; Value = $Theme.Enabled.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $Theme.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $Theme.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Override authentication domain"; Value = $Theme.OverrideAuthenticationDomain.ToString(); }) > $Null
                                    If($Theme.OverrideAuthenticationDomain)
                                    {
                                            $ScriptInformation.Add(@{Data = "     Domain"; Value = $Theme.Domain; }) > $Null
                                    }
                                    $ScriptInformation.Add(@{Data = "Limit access to this theme to members of these AD groups"; Value = $Theme.GroupEnabled.ToString(); }) > $Null
                                    If($Theme.GroupEnabled)
                                    {
                                            ForEach($Group in $Theme.GroupFilters)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Group: $($Group.name) SID: $($Group.sid)"; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  <>                         }
                            If($Text)
                            {
                                    Line 3 "Enable Theme`t`t`t: " $Theme.Enabled.ToString()
                                    Line 3 "Name`t`t`t`t: " $Theme.Name
                                WriteWordLine 3 0 "Remote PC Application"                                   Line 3 "Description`t`t`t: " $Theme.Description
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $ThemeName = $Theme.Name.Replace("<","").Replace(">","")
                                    $rowdata = @()
                                    $columnHeaders = @("Enable Theme",($Script:htmlsb),$Theme.Enabled.ToString(),$htmlwhite)
                                    $rowdata += @(,("Name",($Script:htmlsb),$ThemeName,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$Theme.Description,$htmlwhite))
     
                                    $msg = "General"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                WriteWordLine 4 0 "Application"                                   WriteWordLine 4 0 "Access"
                            }
                            If($Text)
                            {
                                    Line 2 "Access"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            $Results = Get-RASMFA -Id $Theme.MFAId -EA 0 4>$Null
                            
                            If($? -and $Null -ne $Results)
                            {
                                    $MFAProvider = $Results.Name
                            }
                            Else
                            {
                                    $MFAProvider = "Unable to determine MFA provider"
                            }
                            
                            $Results = Get-RASSAMLIDP -SiteId $Site.Id -EA 0 | Where-Object {$_.ThemeId -eq $Theme.Id}
                            
                            If($? -and $Null -ne $Results)
                            {
                                    $SAMLProvider = $Results.Name
                            }
                            Else
                            {
                                    $SAMLProvider = ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
 
                                $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Override authentication domain"; Value = $Theme.OverrideAuthenticationDomain.ToString(); }) > $Null
                                    If($Theme.OverrideAuthenticationDomain)
                                    {
                                $ScriptInformation.Add(@{Data = "Run"; Value = $WinType; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Domain"; Value = $Theme.Domain; }) > $Null
                                    }
                                $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null                                   $ScriptInformation.Add(@{Data = "Limit access to this theme to members of these AD groups"; Value = $Theme.GroupEnabled.ToString(); }) > $Null
                                    If($Theme.GroupEnabled)
                                    {
                                            ForEach($Group in $Theme.GroupFilters)
                                            {
                                $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Group: $($Group.name) SID: $($Group.sid)"; }) > $Null
                                            }
                                    }
                                $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null                                   $ScriptInformation.Add(@{Data = "MFA provider"; Value = $MFAProvider; }) > $Null
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "SAML Single Sign-in IdP"; Value = $SAMLProvider; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
                                 +-  
                                OutputPubItemFilters $PubItem "MSWordPDF"    
                                    
                                OutputPubItemShortcuts $PubItem "MSWordPDF" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
 
                                Line 2 "Information" <>  
                                Line 3 "Remote PC Application`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"    
                                Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description    
                                Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod    
                                Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()    
                                Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate    
                                Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()    
                                Line 3 "Target`t`t`t`t`t`t`t: " $PubItem.Target    
                                Line 3 "Start In`t`t`t`t`t`t: " $PubItem.StartIn    
                                Line 3 "Start automatically when user logs on`t`t`t: " $PubItem.StartOnLogon.ToString()                                   Line 3 "Override authentication domain`t: " $Theme.OverrideAuthenticationDomain.ToString()
                                    
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        Line 3 "Parameters`t`t`t`t`t`t: " $PubItem.Parameters    
                                }    
                                    
                                Line 3 "Settings for Site $xSiteName"    
     
                                If($PubItem.InheritShortcutDefaultSettings)                                   If($Theme.OverrideAuthenticationDomain)
 
                                        If($DefaultCreateShortcutOnDesktop -eq "True") <>                                         Line 6 "Domain  : " $Theme.Domain
                                        {    
                                                Line 3 "Create shortcut on desktop"    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"    
                                        }    
 
                                Else <>  
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                Line 3 "Create shortcut on desktop"                                   Line 3 "Limit access to this theme to "
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"                                   Line 3 "members of these AD groups`t: " $Theme.GroupEnabled.ToString()
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 "Own Filters"    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        Line 3 " User filtering is enabled"    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                Line 10 "  " $Item.Account    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        Line 3 " IP filtering is enabled"    
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        Line 3 " Client filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        Line 3 " MAC filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.GWFilterEnabled)                                   If($Theme.GroupEnabled)
 
                                        Line 3 " Gateway filtering is enabled" <>  
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 " Client device operating system filtering is enabled"    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                Line 10 "  Android"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                Line 10 "  ChromeApp"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                Line 10 "  iOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                Line 10 "  Linux"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                Line 10 "  macOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                Line 10 "  RAS Web Portal"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                Line 10 "  Windows"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                Line 10 "  Wyse"    
                                        }    
                                        Line 0 ""    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)                                           ForEach($Group in $Theme.GroupFilters)
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
 
                                                Line 3 "Available in Site(s)`t`t`t`t`t: " $SiteName <>                                                 Line 7 "  Group: $($Group.name) SID: $($Group.sid)"
 
                                        Else +-  
                                        {    
                                                Line 10 $SiteName    
                                        }    
 
                                Line 0 "" <>                                 Line 3 "MFA provider`t`t`t: " $MFAProvider
                                    Line 3 "SAML Single Sign-in IdP`t`t: " $SAMLProvider
                                Line 2 "Sites"    
                                Line 3 "This published item will be available from the following Sites"    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        Line 10 $SiteName    
                                }    
 
  +-  
                                Line 2 "Remote PC Application"    
                                Line 3 "Application"    
                                Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name    
                                Line 4 "Description`t`t`t`t`t: " $PubItem.Description    
                                Line 4 "Run`t`t`t`t`t`t: " $WinType    
                                Line 4 "Target`t`t`t`t`t`t: " $PubItem.Target    
                                Line 4 "Start In`t`t`t`t`t: " $PubItem.StartIn    
                                Line 4 "Parameters`t`t`t`t`t: " $PubItem.Parameters    
                                Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()    
                                Line 0 ""    
                                    
                                OutputPubItemFilters $PubItem "Text"    
                                    
                                OutputPubItemShortcuts $PubItem "Text" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
 
                                WriteHTMLLine 3 0 "Information" <>                                 $ThemeName = $Theme.Name.Replace("<","").Replace(">","")
 
  <>  
                                $columnHeaders = @("Remote PC Application",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))    
                                $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))    
                                $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))                                   $columnHeaders = @("Override authentication domain",($Script:htmlsb),$Theme.OverrideAuthenticationDomain.ToString(),$htmlwhite)
                                    
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))    
                                }    
                                    
                                $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))    
                                    
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)                                   If($Theme.OverrideAuthenticationDomain)
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
 
                                        $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite)) <>  
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))                                           $rowdata += @(,("     Domain",($Script:htmlsb),$Theme.Domain,$htmlwhite))
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
 
                                If($PubItem.ClientFilterEnabled) <>  
                                {    
                                        $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Limit access to this theme to members of these AD groups",($Script:htmlsb),$Theme.GroupEnabled.ToString(),$htmlwhite))
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)                                   If($Theme.GroupEnabled)
 
                                        $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite)) <>  
                                            
                                        ForEach($item in $PubItem.AllowedGWs)                                           ForEach($Group in $Theme.GroupFilters)
 
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Group: $($Group.name) SID: $($Group.sid)",$htmlwhite))
 
                                If($PubItem.OSFilterEnabled) <>  
                                {    
                                        $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))                                   $rowdata += @(,("MFA provider",($Script:htmlsb),$MFAProvider,$htmlwhite))
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))                                   $rowdata += @(,("SAML Single Sign-in IdP",($Script:htmlsb),$SAMLProvider,$htmlwhite))
                                        }    
                                                                          
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))    
                                        }    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
                            
                                $msg = ""                                   $msg = "Access"
                                $columnWidths = @("200","300")                                   $columnWidths = @("200","400")
 
  <>  
                                WriteHTMLLine 3 0 "Sites"    
                                $rowdata = @()    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)    
                                        }                           }
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Remote PC Application"    
                                $rowdata = @()    
     
                                $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Run",($Script:htmlsb),$WinType,$htmlwhite))    
                                $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))    
                                $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))    
                                $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))    
     
                                $msg = "Application"    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                                                          
                                OutputPubItemFilters $PubItem "HTML"                           If($MSWord -or $PDF)
                                    
                                OutputPubItemShortcuts $PubItem "HTML" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
                        }    
                }    
                ElseIf($PubItem.Type -eq "PCDesktop")    
                {    
                        $DesktopSize = "Unable to determine"    
                        If($PubItem.DesktopSize -eq "FullScreen")    
 
                                $DesktopSize = "Full Screen" <>                                 WriteWordLine 4 0 "Messages"
 
                        ElseIf($PubItem.DesktopSize -eq "UseAvailableArea") <>                         If($Text)
 
                                $DesktopSize = "Use available area" <>                                 Line 2 "Messages"
 
                        Else <>                         If($HTML)
 
                                $DesktopSize = "$($PubItem.Width.ToString())x$($PubItem.Height.ToString())" <>  
                        }                                   #Nothing
                            
                        If($PubItem.AllowMultiMonitor -eq "UseClientSettings")    
                        {    
                                $AllowMultiMonitor = "Use Client Settings"    
 
                        Else +-  
                        {    
                                $AllowMultiMonitor = $PubItem.AllowMultiMonitor.ToString()    
                        }    
 
                                WriteWordLine 3 0 "Information" +-  
                                    
 
                                $ScriptInformation.Add(@{Data = "Remote PC Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null    
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null    
                                        }    
                                }    
     
                                $cnt =-1                                   $cnt = -1
                                ForEach($Site in $PubItem.PublishToSite)                                   ForEach($line in $ThemePostLogonMessage)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name +-  
 
                                                $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "Post-logon message:"; Value = $line; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null
 
  <>                                 $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    $cnt = -1
                                    ForEach($line in $ThemePostLogonMessage)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    Line 3 "Post-logon message: " $line
                                            }
                                            Else
                                            {
                                                    Line 5 "    " $line
                                            }
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $cnt = -1
                                    ForEach($line in $ThemePostLogonMessage)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $columnHeaders = @("Post-logon message:",($Script:htmlsb),$line,$htmlwhite)
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))
                                            }
                                    }
     
                                    $msg = "Messages"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/URLs"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/URLs"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Theme login page:"; Value = $ThemeUserPortalURL; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Show Parallels Client download URL"; Value = $ThemeShowDownloadURL; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Override download URL for branded Parallels Client (Windows)"; Value = $ThemeOverrideDownloadURL; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                $Table.Columns.Item(2).Width = 300;                                   $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
 
  -+                                 
                                    If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty
                                    {
                                            WriteWordLine 4 0 "Footer URLs:"
                                            [System.Collections.Hashtable[]] $URLWordTable = @();
                                            
                                            ForEach($FooterURL in $ThemeFooterURLs)
                                            {
                                                    $URLTableRowHash = @{
                                                    URL     = $FooterURL.URL;
                                                    Text    = $FooterURL.Text;
                                                    Tooltip = $FooterURL.Tooltip;
                                                    }
                                                    $URLWordTable += $URLTableRowHash;
                                            }
 
  <>                                         If($URLWordTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $URLWordTable `
                                                    -Columns  URL,Text,Tooltip `
                                                    -Headers  "URL","Text","Tooltip"`
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 150;
                                                    $Table.Columns.Item(2).Width = 150;
                                                    $Table.Columns.Item(3).Width = 150;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                WriteWordLine 3 0 "Sites"                                                   WriteWordLine 0 0 ""
                                            }
                                    }
                                    Else
                                    {
                                            WriteWordLine 4 0 "Footer URLs:"
                                            WriteWordLine 0 0 "There are no Footer URLs"
                                            WriteWordLine 0 0 ""
                                    }       
                            }
                            If($Text)
                            {
                                    Line 3 "Theme login page`t`t  : " $ThemeUserPortalURL
                                    Line 3 "Show Parallels Client download URL: " $ThemeShowDownloadURL
                                    Line 3 "Override download URL for branded "
                                    Line 3 "Parallels Client (Windows)`t  : " $ThemeOverrideDownloadURL
                                    Line 0 ""
     
                                    If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty
                                    {
                                            Line 3 "Footer URLs:"
                                            Line 3 "URL                             Text                            Tooltip                       "
                                            Line 3 "=============================================================================================="
                                            #       123456789012345678901234567890SS123456789012345678901234567890SS123456789012345678901234567890
     
                                            ForEach($FooterURL in $ThemeFooterURLs)
                                            {
                                                    Line 3 ( "{0,-30}  {1,-30}  {2,-30}" -f `
                                                    $FooterURL.URL, $FooterURL.Text, $FooterURL.Tooltip)
                                            }
                                            
                                            Line 0 ""
                                    }
                                    Else
                                    {
                                            Line 3 "Footer URLs:"
                                            Line 3 "There are no Footer URLs"
                                            Line 0 ""
                                    }       
                            }
                            If($HTML)
                            {
                                    $ThemeName = $Theme.Name.Replace("<","").Replace(">","")
                                    $rowdata = @()
                                    $columnHeaders = @("Theme login page:",($Script:htmlsb),$ThemeUserPortalURL,$htmlwhite)
                                    $rowdata += @(,("Show Parallels Client download URL",($Script:htmlsb),$ThemeShowDownloadURL,$htmlwhite))
                                    $rowdata += @(,("Override download URL for branded Parallels Client (Windows)",($Script:htmlsb),$ThemeOverrideDownloadURL,$htmlwhite))
     
                                    $msg = "User Portal (Web client)/URLs"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty
                                    {
                                            $rowdata = @()
     
                                            ForEach($FooterURL in $ThemeFooterURLs)
                                            {
                                                    $rowdata += @(,(
                                                    $FooterURL.URL,$htmlwhite,
                                                    $FooterURL.Text,$htmlwhite,
                                                    $FooterURL.Tooltip,$htmlwhite))
                                            }
     
                                            $columnHeaders = @(
                                            "URL",($Script:htmlsb),
                                            "Text",($Script:htmlsb),
                                            "Tooltip",($Script:htmlsb))
     
                                            $msg = "Footer URLs:"
                                            $columnWidths = @("150","150","150")
                                            FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "450"
                                            WriteHTMLLine 0 0 ""
                                    }
                                    Else
                                    {
                                            WriteHTMLLine 4 0 "Footer URLs:"
                                            WriteHTMLLine 0 0 "There are no Footer URLs"
                                            WriteHTMLLine 0 0 ""
                                    }       
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/Branding"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Branding"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
 
  -+                                 $ScriptInformation.Add(@{Data = "Webpage title"; Value = $Theme.UserPortal.Branding.WebpageTitle; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Login to"; Value = $Theme.UserPortal.Branding.LoginTo; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Company logo"; Value = $ThemeCompanyLogo; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Favicon icon"; Value = $ThemeFaviconIcon; }) > $Null
 
  <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Webpage title`t: " $Theme.UserPortal.Branding.WebpageTitle
                                    Line 3 "Login to`t: " $Theme.UserPortal.Branding.LoginTo
                                    Line 3 "Company logo`t: " $ThemeCompanyLogo
                                    Line 3 "Favicon icon`t: " $ThemeFaviconIcon
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Webpage title",($Script:htmlsb),$Theme.UserPortal.Branding.WebpageTitle,$htmlwhite)
                                    $rowdata += @(,("Login to",($Script:htmlsb),$Theme.UserPortal.Branding.LoginTo,$htmlwhite))
                                    $rowdata += @(,("Company logo",($Script:htmlsb),$ThemeCompanyLogo,$htmlwhite))
                                    $rowdata += @(,("Favicon icon",($Script:htmlsb),$ThemeFaviconIcon,$htmlwhite))
     
                                    $msg = "User Portal (Web client)/Branding"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/Colors"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Colors"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
     
                            $HeaderBackgroundColor      = '{0:X}' -f $Theme.UserPortal.Color.HeaderBackgroundColor     
                            $SubHeaderBackgroundColor   = '{0:X}' -f $Theme.UserPortal.Color.SubHeaderBackgroundColor  
                            $SubHeaderTextColor         = '{0:X}' -f $Theme.UserPortal.Color.SubHeaderTextColor        
                            $WorkAreaBackgroundColor    = '{0:X}' -f $Theme.UserPortal.Color.WorkAreaBackgroundColor   
                            $WorkAreaTextColor          = '{0:X}' -f $Theme.UserPortal.Color.WorkAreaTextColor         
                            $ButtonsBackgroundColor     = '{0:X}' -f $Theme.UserPortal.Color.ButtonsBackgroundColor    
                            $ButtonsTextColor           = '{0:X}' -f $Theme.UserPortal.Color.ButtonsTextColor          
                            $SelectionHighlightingColor = '{0:X}' -f $Theme.UserPortal.Color.SelectionHighlightingColor
                            $AlertBackgroundColor       = '{0:X}' -f $Theme.UserPortal.Color.AlertBackgroundColor      
                            $AlertTextColor             = '{0:X}' -f $Theme.UserPortal.Color.AlertTextColor            
     
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Header background" ; Value = $HeaderBackgroundColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Sub-header background" ; Value = $SubHeaderBackgroundColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Sub-header text" ; Value = $SubHeaderTextColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Work area background" ; Value = $WorkAreaBackgroundColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Work area text" ; Value = $WorkAreaTextColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Buttons background and links" ; Value = $ButtonsBackgroundColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Button text" ; Value = $ButtonsTextColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Selection highlighting" ; Value = $SelectionHighlightingColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Alert background" ; Value = $AlertBackgroundColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Alert text" ; Value = $AlertTextColor; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Header background`t`t: " $HeaderBackgroundColor
                                    Line 3 "Sub-header background`t`t: " $SubHeaderBackgroundColor
                                    Line 3 "Sub-header text`t`t`t: " $SubHeaderTextColor
                                    Line 3 "Work area background`t`t: " $WorkAreaBackgroundColor
                                    Line 3 "Work area text`t`t`t: " $WorkAreaTextColor
                                    Line 3 "Buttons background and links`t: " $ButtonsBackgroundColor
                                    Line 3 "Button text`t`t`t: " $ButtonsTextColor
                                    Line 3 "Selection highlighting`t`t: " $SelectionHighlightingColor
                                    Line 3 "Alert background`t`t: " $AlertBackgroundColor
                                    Line 3 "Alert text`t`t`t: " $AlertTextColor
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Header background" ,($Script:htmlsb),$HeaderBackgroundColor,$htmlwhite)
                                    $rowdata += @(,("Sub-header background" ,($Script:htmlsb),$SubHeaderBackgroundColor,$htmlwhite))
                                    $rowdata += @(,("Sub-header text" ,($Script:htmlsb),$SubHeaderTextColor,$htmlwhite))
                                    $rowdata += @(,("Work area background" ,($Script:htmlsb),$WorkAreaBackgroundColor,$htmlwhite))
                                    $rowdata += @(,("Work area text" ,($Script:htmlsb),$WorkAreaTextColor,$htmlwhite))
                                    $rowdata += @(,("Buttons background and links",($Script:htmlsb),$ButtonsBackgroundColor,$htmlwhite))
                                    $rowdata += @(,("Button text" ,($Script:htmlsb),$ButtonsTextColor,$htmlwhite))
                                    $rowdata += @(,("Selection highlighting" ,($Script:htmlsb),$SelectionHighlightingColor,$htmlwhite))
                                    $rowdata += @(,("Alert background" ,($Script:htmlsb),$AlertBackgroundColor,$htmlwhite))
                                    $rowdata += @(,("Alert text" ,($Script:htmlsb),$AlertTextColor,$htmlwhite))
     
                                    $msg = "User Portal (Web client)/Colors"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/Language bar"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Language bar"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Default language"   ; Value = $Theme.UserPortal.LanguageBar.Default.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "English"            ; Value = $Theme.UserPortal.LanguageBar.en_US.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "German"             ; Value = $Theme.UserPortal.LanguageBar.de_DE.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Japanese"           ; Value = $Theme.UserPortal.LanguageBar.ja_JP.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Russian"            ; Value = $Theme.UserPortal.LanguageBar.ru_RU.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "French"             ; Value = $Theme.UserPortal.LanguageBar.fr_FR.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Spanish"            ; Value = $Theme.UserPortal.LanguageBar.es_ES.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Italian"            ; Value = $Theme.UserPortal.LanguageBar.it_IT.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Portuguese"         ; Value = $Theme.UserPortal.LanguageBar.pt_BR.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Chinese Simplified" ; Value = $Theme.UserPortal.LanguageBar.zh_CN.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Chinese Traditional"; Value = $Theme.UserPortal.LanguageBar.zh_TW.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Korean"             ; Value = $Theme.UserPortal.LanguageBar.ko_KR.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Dutch"              ; Value = $Theme.UserPortal.LanguageBar.nl_NL.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Default language`t: "    $Theme.UserPortal.LanguageBar.Default.ToString()
                                    Line 3 "English`t`t`t: "         $Theme.UserPortal.LanguageBar.en_US.ToString()
                                    Line 3 "German`t`t`t: "          $Theme.UserPortal.LanguageBar.de_DE.ToString()
                                    Line 3 "Japanese`t`t: "          $Theme.UserPortal.LanguageBar.ja_JP.ToString()
                                    Line 3 "Russian`t`t`t: "         $Theme.UserPortal.LanguageBar.ru_RU.ToString()
                                    Line 3 "French`t`t`t: "          $Theme.UserPortal.LanguageBar.fr_FR.ToString()
                                    Line 3 "Spanish`t`t`t: "         $Theme.UserPortal.LanguageBar.es_ES.ToString()
                                    Line 3 "Italian`t`t`t: "         $Theme.UserPortal.LanguageBar.it_IT.ToString()
                                    Line 3 "Portuguese`t`t: "        $Theme.UserPortal.LanguageBar.pt_BR.ToString()
                                    Line 3 "Chinese Simplified`t: "  $Theme.UserPortal.LanguageBar.zh_CN.ToString()
                                    Line 3 "Chinese Traditional`t: " $Theme.UserPortal.LanguageBar.zh_TW.ToString()
                                    Line 3 "Korean`t`t`t: "          $Theme.UserPortal.LanguageBar.ko_KR.ToString()
                                    Line 3 "Dutch`t`t`t: "           $Theme.UserPortal.LanguageBar.nl_NL.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Default language",($Script:htmlsb),$Theme.UserPortal.LanguageBar.Default.ToString(),$htmlwhite)
                                    $rowdata += @(,("English"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.en_US.ToString(),$htmlwhite))
                                    $rowdata += @(,("German"             ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.de_DE.ToString(),$htmlwhite))
                                    $rowdata += @(,("Japanese"           ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.ja_JP.ToString(),$htmlwhite))
                                    $rowdata += @(,("Russian"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.ru_RU.ToString(),$htmlwhite))
                                    $rowdata += @(,("French"             ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.fr_FR.ToString(),$htmlwhite))
                                    $rowdata += @(,("Spanish"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.es_ES.ToString(),$htmlwhite))
                                    $rowdata += @(,("Italian"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.it_IT.ToString(),$htmlwhite))
                                    $rowdata += @(,("Portuguese"         ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.pt_BR.ToString(),$htmlwhite))
                                    $rowdata += @(,("Chinese Simplified" ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.zh_CN.ToString(),$htmlwhite))
                                    $rowdata += @(,("Chinese Traditional",($Script:htmlsb),$Theme.UserPortal.LanguageBar.zh_TW.ToString(),$htmlwhite))
                                    $rowdata += @(,("Korean"             ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.ko_KR.ToString(),$htmlwhite))
                                    $rowdata += @(,("Dutch"              ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.nl_NL.ToString(),$htmlwhite))
     
                                    $msg = "User Portal (Web client)/Language bar"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/Messages"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Messages"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                $cnt =-1                                   $cnt = -1
                                ForEach($Site in $PubItem.PublishToSite)                                   ForEach($line in $ThemeUserPortalPrelogonMessage)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name +-  
 
                                                $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "Pre-logon message:"; Value = $line; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
                                WriteWordLine 3 0 "Remote PC Desktop" +-  
                                WriteWordLine 4 0 "Remote PC Desktop"    
 
  <>                                 $ScriptInformation.Add(@{Data = "Override post-logon message"; Value = $Theme.UserPortal.Message.OverridePostLogonMessage.ToString(); }) > $Null
                                    If($Theme.UserPortal.Message.OverridePostLogonMessage)
                                    {
                                            ForEach($line in $ThemeUserPortalPostlogonMessage)
                                            {
                                $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null                                           }
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null                                   }
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  -+                         }
                            If($Text)
                            {
                                    $cnt = -1
                                    ForEach($line in $ThemeUserPortalPrelogonMessage)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    Line 3 "Pre-logon message: " $line
                                            }
                                            Else
                                            {
                                                    Line 5 "    " $line
                                            }
                                    }
                                    Line 0 ""
 
  <>                                 Line 3 "Override post-logon message: " $Theme.UserPortal.Message.OverridePostLogonMessage.ToString()
                                    If($Theme.UserPortal.Message.OverridePostLogonMessage)
                                    {
                                            ForEach($line in $ThemeUserPortalPostlogonMessage)
                                            {
                                                    Line 5 "    " $line
                                            }
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $cnt = -1
                                    ForEach($line in $ThemeUserPortalPrelogonMessage)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $columnHeaders = @("Pre-logon message:",($Script:htmlsb),$line,$htmlwhite)
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))
                                            }
                                    }
     
                                    $msg = "User Portal (Web client)/Messages"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    $rowdata = @()
                                    $columnHeaders = @("Override post-logon message",($Script:htmlsb),$Theme.UserPortal.Message.OverridePostLogonMessage.ToString(),$htmlwhite)
                                    If($Theme.UserPortal.Message.OverridePostLogonMessage)
                                    {
                                            ForEach($line in $ThemeUserPortalPostlogonMessage)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))
                                            }
                                    }
     
                                    $msg = ""
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/Input prompt"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Input prompt"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            $InputPromptTable = @()
                            
                            $InputPromptTable += @{
                                    Language = "German"
                                    LoginHint = $Theme.UserPortal.InputPrompt.de_DE.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.de_DE.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "English"
                                    LoginHint = $Theme.UserPortal.InputPrompt.en_US.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.en_US.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Japanese"
                                    LoginHint = $Theme.UserPortal.InputPrompt.ja_JP.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.ja_JP.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Russian"
                                    LoginHint = $Theme.UserPortal.InputPrompt.ru_RU.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.ru_RU.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "French"
                                    LoginHint = $Theme.UserPortal.InputPrompt.fr_FR.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.fr_FR.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Spanish"
                                    LoginHint = $Theme.UserPortal.InputPrompt.es_ES.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.es_ES.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Italian"
                                    LoginHint = $Theme.UserPortal.InputPrompt.it_IT.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.it_IT.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Portuguese"
                                    LoginHint = $Theme.UserPortal.InputPrompt.pt_BR.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.pt_BR.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Chinese Simplified"
                                    LoginHint = $Theme.UserPortal.InputPrompt.zh_CN.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.zh_CN.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Chinese Traditional"
                                    LoginHint = $Theme.UserPortal.InputPrompt.zh_TW.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.zh_TW.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Korean"
                                    LoginHint = $Theme.UserPortal.InputPrompt.ko_KR.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.ko_KR.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Dutch"
                                    LoginHint = $Theme.UserPortal.InputPrompt.nl_NL.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.nl_NL.PasswordHint
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
     
                                    If($InputPromptTable.Count -gt 0)
                                    {
                                            $Table = AddWordTable -Hashtable $InputPromptTable `
                                            -Columns Language, LoginHint, PasswordHint `
                                            -Headers "Language", "Login hint", "Password hint" `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 100;
                                            $Table.Columns.Item(2).Width = 100;
                                            $Table.Columns.Item(3).Width = 100;
                                            
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                WriteWordLine 4 0 "Properties"                                           WriteWordLine 0 0 ""
                                    }
                            }
                            If($Text)
                            {
                                    Line 3 "Language             Login hint           Password hint"
                                    Line 3 "======================================================="
                                    #       1234567890123456789SS1234567890123456789SS1234567890123
                                    #               Chinese Traditional  utilisateur@domaine  mot de passe
                                    #                            ユーザー@ドメイン
     
                                    ForEach($Item in $InputPromptTable)
                                    {
                                            Line 3 ( "{0,-19}  {1,-19}  {2,-13}" -f 
                                                    $Item.Language, 
                                                    $Item.LoginHint, 
                                                    $Item.PasswordHint
                                            )
                                    }
                                    
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
     
                                    ForEach($Item in $InputPromptTable)
                                    {
                                            $rowdata += @(,(
                                                    $Item.Language,$htmlwhite,
                                                    $Item.LoginHint,$htmlwhite,
                                                    $Item.PasswordHint,$htmlwhite)
                                            )
                                    }
                                    
                                    $columnHeaders = @(
                                            "Language",($Script:htmlsb),
                                            "Login hint",($Script:htmlsb),
                                            "Pasword hint",($Script:htmlsb)
                                    )
     
                                    $msg = "User Portal (Web client)/Input prompt"
                                    $columnWidths = @("110","120","100")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/Secure Gateway"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Secure Gateway"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
 
  <>                                 $ScriptInformation.Add(@{Data = "Override Secure Gateway settings for theme"; Value = $Theme.UserPortal.Gateway.OverrideGatewaySettings.ToString(); }) > $Null
                                #$ScriptInformation.Add(@{Data = "Select Remote PC"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Client"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $ThemeUserPortalLaunchSessionsUsing; }) > $Null
                                    Switch($Theme.UserPortal.Gateway.LaunchMethod)
                                    {
                                            "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"  
                                            {
                                                    $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $Theme.UserPortal.Gateway.AllowLaunchMethod.ToString(); }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(); }) > $Null
                                                    Break
                                            }
                                            "Launch_Applications_with_Parallels_Client"                                             
                                            {
                                                    Break
                                            }
                                            "Launch_Applications_with_Browser_HTML5"                                                
                                            {
                                                    $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(); }) > $Null
                                                    Break
                                            }
                                    }
                                    $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $Theme.UserPortal.Gateway.Pre2000Cred.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Allow embedding of User Portal into other web pages"; Value = $Theme.UserPortal.Gateway.AllowEmbed.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow file transfer command"; Value = $ThemeHTMLFileTransfer; }) > $Null
                                $ScriptInformation.Add(@{Data = "Multi-Monitor"; Value = $AllowMultiMonitor; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow clipboard command"; Value = $ThemeHTMLClipboardDirection; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $Theme.UserPortal.Gateway.AllowCORS.ToString(); }) > $Null
                                    If($Theme.UserPortal.Gateway.AllowCORS)
                                    {
                                            $cnt=-1
                                            ForEach($Domain in $Theme.UserPortal.Gateway.AllowedDomainsForCORS)
                                            {
                                                    $cnt++
                                                                                  
                                                    If($cnt -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "Allow domains"; Value = $Domain; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $Domain; }) > $Null
                                                    }
                                            }
                                            $ScriptInformation.Add(@{Data = "Browser cache time"; Value = "$($Theme.UserPortal.Gateway.BrowserCacheTimeInMonths.ToString()) months"; }) > $Null
                                    }
     
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  +-  
                                OutputPubItemFilters $PubItem "MSWordPDF"    
     
                                OutputPubItemShortcuts $PubItem "MSWordPDF" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
 
                                Line 2 "Information" <>                                 Line 3 "Override Secure Gateway settings for theme: " $Theme.UserPortal.Gateway.OverrideGatewaySettings.ToString()
                                Line 3 "Remote PC Desktop`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"    
                                Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description    
                                Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod    
                                Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()    
                                Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate    
                                Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()    
                                Line 3 "Desktop Size`t`t`t`t`t`t: " $DesktopSize    
     
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                Line 3 "Create shortcut on desktop"    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                Line 3 "Create shortcut on desktop"    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"    
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 "Own Filters"                                   Line 3 "Client"
                                }                                   Line 4 "Launch sessions using`t`t`t: " $ThemeUserPortalLaunchSessionsUsing
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        Line 3 " User filtering is enabled"    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)                                   Switch($Theme.UserPortal.Gateway.LaunchMethod)
                                        {    
                                                Line 10 "  " $Item.Account    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.IPFilterEnabled)    
 
                                        Line 3 " IP filtering is enabled" <>                                         "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"  
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
 
                                                ForEach($item in $PubItem.AllowedIP4s) <>                                                 Line 4 "Allow user to select a launch method`t: " $Theme.UserPortal.Gateway.AllowLaunchMethod.ToString()
                                                {                                                   Line 4 "Allow opening applications in a new tab`t: " $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString()
                                                        If($item.From -eq $item.To)    
                                                        {                                                   Break
                                                                Line 10 "  " $item.From    
                                                        }                                           }
                                                        Else                                           "Launch_Applications_with_Parallels_Client"                                             
                                                        {                                           {
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
                                                    Break
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
 
                                        Line 0 "" <>                                         "Launch_Applications_with_Browser_HTML5"                                                
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {                                           {
                                        Line 3 " Client filtering is enabled"                                                   Line 4 "Allow opening applications in a new tab`t: " $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString()
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {                                                   Break
                                                Line 10 "  " $Item    
 
                                        Line 0 "" +-  
 
                                If($PubItem.MACFilterEnabled) <>                                 Line 4 "Use Pre Windows 2000 login format`t: " $Theme.UserPortal.Gateway.Pre2000Cred.ToString()
                                {    
                                        Line 3 " MAC filtering is enabled"                                   Line 4 "Allow embedding of User Portal "
                                                                          Line 4 "Client into other web pages`t`t: " $Theme.UserPortal.Gateway.AllowEmbed.ToString()
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        Line 3 " Gateway filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 " Client device operating system filtering is enabled"                                   Line 4 "Allow file transfer command`t`t: " $ThemeHTMLFileTransfer
                                                                          Line 4 "Allow clipboard command`t`t`t: " $ThemeHTMLClipboardDirection
                                        If($PubItem.AllowedOSes.Android)                                   Line 4 "Allow cross-origin resource sharing`t: " $Theme.UserPortal.Gateway.AllowCORS.ToString()
                                        {    
                                                Line 10 "  Android"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)                                   If($Theme.UserPortal.Gateway.AllowCORS)
                                        {                                   {
                                                Line 10 "  ChromeApp"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                Line 10 "  iOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                Line 10 "  Linux"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                Line 10 "  macOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                Line 10 "  RAS Web Portal"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                Line 10 "  Windows"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                Line 10 "  Wyse"    
                                        }    
                                        Line 0 ""    
                                }    
     
                                $cnt =-1                                           $cnt=-1
                                ForEach($Site in $PubItem.PublishToSite)                                           ForEach($Domain in $Theme.UserPortal.Gateway.AllowedDomainsForCORS)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                                                                          
                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                        {                                                   {
                                                Line 3 "Available in Site(s):`t`t`t`t`t" $SiteName                                                           Line 5 "Allow domains`t`t`t: " $Domain
                                        }                                                   }
                                        Else                                                   Else
                                        {                                                   {
                                                Line 10 $SiteName                                                           Line 9 "  " $Domain
                                        }                                                   }
                                }                                           }
                                Line 0 ""                                           Line 5 "Browser cache time`t`t: "  "$($Theme.UserPortal.Gateway.BrowserCacheTimeInMonths.ToString()) months"
     
                                Line 2 "Sites"    
                                Line 3 "This published item will be available from the following Sites"    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        Line 10 $SiteName    
 
                                Line 0 "" +-  
 
                                Line 2 "Remote PC Desktop" +-  
                                Line 3 "Remote PC Desktop"    
                                Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name    
                                Line 4 "Description`t`t`t`t`t: " $PubItem.Description    
                                Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()    
 
                                Line 3 "Properties" +-  
                                Line 4 "Desktop Size`t`t`t`t`t: " $DesktopSize    
                                Line 4 "Multi-Monitor`t`t`t`t`t: " $AllowMultiMonitor    
                                Line 0 ""    
     
                                OutputPubItemFilters $PubItem "Text"    
                                    
                                OutputPubItemShortcuts $PubItem "Text" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
 
                                WriteHTMLLine 3 0 "Information" +-  
 
  <>  
                                $columnHeaders = @("Remote PC Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))                                   $columnHeaders = @("Override Secure Gateway settings for theme",($Script:htmlsb),$Theme.UserPortal.Gateway.OverrideGatewaySettings.ToString(),$htmlwhite)
                                $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))                                   $rowdata += @(,("Client",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))                                   $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$ThemeUserPortalLaunchSessionsUsing,$htmlwhite))
                                $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))    
                                If($PubItem.InheritShortcutDefaultSettings)                                   Switch($Theme.UserPortal.Gateway.LaunchMethod)
 
                                        If($DefaultCreateShortcutOnDesktop -eq "True") <>                                         "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"  
 
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite)) <>  
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))                                                   $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$Theme.UserPortal.Gateway.AllowLaunchMethod.ToString(),$htmlwhite))
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))                                                   $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))
                                        }                                                   Break
                                }                                           }
                                Else                                           "Launch_Applications_with_Parallels_Client"                                             
                                {                                           {
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {                                                   Break
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
 
                                        If($PubItem.CreateShortcutInStartFolder) <>                                         "Launch_Applications_with_Browser_HTML5"                                                
 
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite)) <>                                                 $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
                                                    Break
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))    
 
                                If($PubItem.IPFilterEnabled) <>  
                                {    
                                        $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb), $Theme.UserPortal.Gateway.Pre2000Cred.ToString(),$htmlwhite))
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Allow embedding of User Portal into other web pages",($Script:htmlsb), $Theme.UserPortal.Gateway.AllowEmbed.ToString(),$htmlwhite))
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Allow file transfer command",($Script:htmlsb),$ThemeHTMLFileTransfer,$htmlwhite))
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Allow clipboard command",($Script:htmlsb),$ThemeHTMLClipboardDirection,$htmlwhite))
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$Theme.UserPortal.Gateway.AllowCORS.ToString(),$htmlwhite))
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)                                   If($Theme.UserPortal.Gateway.AllowCORS)
                                        {                                   {
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))    
                                        }    
                                }    
     
                                $cnt =-1                                           $cnt=-1
                                ForEach($Site in $PubItem.PublishToSite)                                           ForEach($Domain in $Theme.UserPortal.Gateway.AllowedDomainsForCORS)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                                                                          
                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                        {                                                   {
                                                $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))                                                           $rowdata += @(,("Allow domains",($Script:htmlsb),$Domain,$htmlwhite))
                                        }                                                   }
                                        Else                                                   Else
                                        {                                                   {
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),$Domain,$htmlwhite))
                                        }                                                   }
                                }                                           }
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Sites"    
                                $rowdata = @()    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)                                           $rowdata += @(,("Browser cache time",($Script:htmlsb),"$($Theme.UserPortal.Gateway.BrowserCacheTimeInMonths.ToString()) months",$htmlwhite))
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
 
                                $msg = "" <>  
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Remote PC Desktop"    
                                $rowdata = @()    
                                $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)                                   $msg = "User Portal (Web client)/Secure Gateway"
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","300")                                   $columnWidths = @("300","300")
 
  +-  
                                WriteHTMLLine 4 0 "Properties"    
                                $rowdata = @()    
                                $columnHeaders = @("Select Remote PC",($Script:htmlsb),"",$htmlwhite)    
                                $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))    
                                $rowdata += @(,("Multi-Monitor",($Script:htmlsb),$AllowMultiMonitor,$htmlwhite))    
                                    
                                $msg = "Remote PC Desktop"    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                OutputPubItemFilters $PubItem "HTML"    
     
                                OutputPubItemShortcuts $PubItem "HTML" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
 
                } <>  
                ElseIf($PubItem.Type -eq "RDSApp")                           If($MSWord -or $PDF)
                {    
                        Switch ($PubItem.ConCurrentLicenses)    
 
                                0               {$ConCurrentLicenses = "Unlimited"; Break} <>                                 WriteWordLine 4 0 "User Portal (Web client)/Legal policies"
                                Default {$ConCurrentLicenses = $PubItem.ConCurrentLicenses.ToString(); Break}     
 
                        <>                         If($Text)
                        Switch ($PubItem.DisableSessionSharing)    
 
                                $False  {$SessionSharing = "Enabled"; Break} <>                                 Line 2 "User Portal (Web client)/Legal policies"
                                $True   {$SessionSharing = "Disabled"; Break}    
                                Default {$SessionSharing = "Unable to determine Session Sharing state: $($PubItem.DisableSessionSharing)"; Break}    
 
                        <>                         If($HTML)
                        Switch ($PubItem.PublishFrom)    
 
                                "All"           {$PublishedFrom = "All Servers in Site"; Break} <>  
                                "Group"         {$PublishedFrom = "Server Groups:"; Break}    
                                "Server"        {$PublishedFrom = "Individual Servers:"; Break}    
                                Default         {$PublishedFrom = "Unable to determine Published From: $($PubItem.PublishFrom)"; Break}    
                        }                                   #Nothing
                            
                        Switch ($PubItem.LicenseLimitNotify)    
                        {    
                                "WarnUserAndNoStart"            {$LicenseLimitNotify ="Warn user and do not start"; Break}    
                                "WarnUserAndStart"                      {$LicenseLimitNotify ="Warn user and start"; Break}    
                                "NotifyAdminAndStart"           {$LicenseLimitNotify ="Notify administrator and start"; Break}    
                                "NotifyUserAdminAndStart"       {$LicenseLimitNotify ="Notify user, administrator and start"; Break}    
                                "NotifyUserAdminAndNoStart"     {$LicenseLimitNotify ="Notify user, administrator and do not start"; Break}    
                                Default {$LicenseLimitNotify ="Unable to determine If limit is exceeded: $($PubItem.LicenseLimitNotify)"; Break}    
 
                        Switch ($PubItem.ColorDepth) +-  
                        {    
                                "Colors8Bit"            {$ColorDepth = "256 Colors"; Break}    
                                "Colors15Bit"           {$ColorDepth = "High Color (15 bit)"; Break}    
                                "Colors16Bit"           {$ColorDepth = "High Color (16 bit)"; Break}    
                                "Colors24Bit"           {$ColorDepth = "True Color (24 bit)"; Break}    
                                "Colors32Bit"           {$ColorDepth = "Highest Quality (32 bit)"; Break}    
                                "ClientSpecified"       {$ColorDepth = "Client Specified"; Break}    
                                Default                         {$ColorDepth = "Unable to determine Color Depth: $($PubItem.ColorDepth)"; Break}    
                        }    
                            
                        Switch($PubItem.EnabledMode)    
                        {    
                                "Disabled"              {$PubItemMode = "Disabled"; Break}    
                                "Enabled"               {$PubItemMode = "Enabled"; Break}    
                                "Maintenance"   {$PubItemMode = "In maintenance"; Break}    
                                Default                 {$PubItemMode = "Unable to determine Enabled Mode: $($PubItem.EnabledMode)"; Break}    
                        }    
     
 
                                WriteWordLine 3 0 "Information" +-  
 
                                $ScriptInformation.Add(@{Data = "Application"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Status"; Value = $PubItemMode; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null    
     
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null    
                                }    
                                    
                                If($PubItem.EnableFileExtensions)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Associate the following file extensions"; Value = ""; }) > $Null    
                                        ForEach($Item in $PubItem.FileExtensions)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                   $ScriptInformation.Add(@{Data = "Cookie consent"; Value = ""; }) > $Null
                                        }    
                                }    
                                    
                                If($PubItem.InheritLicenseDefaultSettings)    
                                {    
                                        If($DefaultOneInstancePerUser)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null    
                                        }    
                                        $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $DefaultConCurrentLicenses; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Enable cookie consent"; Value = $Theme.UserPortal.LegalPolicies.AllowCookieConsent.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $DefaultLicenseLimitNotify; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $DefaultDisableSessionSharing ; }) > $Null    
                                }    
                                Else    
                                {    
                                        If($PubItem.OneInstancePerUser)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null    
                                        }    
                                        $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $ConCurrentLicenses; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $LicenseLimitNotify; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $SessionSharing; }) > $Null    
                                }    
     
                                $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null    
                                    
                                If($PubItem.PublishFrom -eq "Server")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromServer)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Published from"; Value = "All Servers in Site"; }) > $Null    
                                }    
     
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "End User License Agreement"; Value = ""; }) > $Null
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null    
                                        }    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Enable EULA"; Value = $Theme.UserPortal.LegalPolicies.AllowEULA.ToString(); }) > $Null
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null    
                                        }    
                                }    
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  -+                         }
                            If($Text)
                            {
                                    Line 3 "Cookie consent" 
                                    Line 4 "Enable cookie consent`t: " $Theme.UserPortal.LegalPolicies.AllowCookieConsent.ToString()
                                    Line 3 "End User License Agreement" 
                                    Line 4 "Enable EULA`t`t: " $Theme.UserPortal.LegalPolicies.AllowEULA.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Cookie consent",($Script:htmlsb),"",$htmlwhite)
                                    $rowdata += @(,("     Enable cookie consent",($Script:htmlsb),$Theme.UserPortal.LegalPolicies.AllowCookieConsent.ToString(),$htmlwhite))
                                    $rowdata += @(,("End User License Agreement",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("     Enable EULA",($Script:htmlsb), $Theme.UserPortal.LegalPolicies.AllowEULA.ToString(),$htmlwhite))
 
  <>                                 $msg = "User Portal (Web client)/Legal policies"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                WriteWordLine 3 0 "Sites"                                   WriteWordLine 4 0 "Windows client/Branding"
                            }
                            If($Text)
                            {
                                    Line 2 "Windows client/Branding"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
 
  -+                                 $ScriptInformation.Add(@{Data = "Company name"; Value = $Theme.WindowsClient.Branding.CompanyName; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Application name"; Value = $Theme.WindowsClient.Branding.ApplicationName; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Connection banner"; Value = $ThemeConnectionBanner; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Application icon"; Value = $ThemeApplicationIcon; }) > $Null
 
  <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                $cnt =-1                                   -List `
                                ForEach($Site in $PubItem.PublishToSite)                                   -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                                {                           {
                                        $cnt++                                   Line 3 "Company name`t`t: " $Theme.WindowsClient.Branding.CompanyName
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name                                   Line 3 "Application name`t: " $Theme.WindowsClient.Branding.ApplicationName
                                    Line 3 "Connection banner`t: " $ThemeConnectionBanner
                                    Line 3 "Application icon`t: " $ThemeApplicationIcon
                                    Line 0 ""
                                                                   }
                                        If($cnt -eq 0)                           If($HTML)
                                        {                           {
                                    $rowdata = @()
                                    $columnHeaders = @("Company name",($Script:htmlsb),$Theme.WindowsClient.Branding.CompanyName,$htmlwhite)
                                                $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null                                   $rowdata += @(,("Application name",($Script:htmlsb),$Theme.WindowsClient.Branding.ApplicationName,$htmlwhite))
                                    $rowdata += @(,("Connection banner",($Script:htmlsb),$ThemeConnectionBanner,$htmlwhite))
                                    $rowdata += @(,("Application icon",($Script:htmlsb),$ThemeApplicationIcon,$htmlwhite))
     
                                    $msg = "Windows client/Branding"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                                        }                           }
                                        Else    
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Windows client/Messages"
                            }
                            If($Text)
                            {
                                    Line 2 "Windows client/Messages"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Override post-logon message"; Value = $Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString(); }) > $Null
                                    If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)
                                    {
                                            ForEach($line in $ThemeWindowsPostlogonMessage)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  <>                         }
                                WriteWordLine 3 0 "Publish from"                           If($Text)
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                If($PubItem.PublishFrom -eq "Server")    
                                {                           {
                                        $cnt = -1                                   Line 3 "Override post-logon message: " $Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString()
                                        ForEach($Item in $PubItem.PublishFromServer)                                   If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)
                                        {                                   {
                                                $cnt++                                           ForEach($line in $ThemeWindowsPostlogonMessage)
                                                    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                    
                                                If($cnt -eq 0)    
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null                                                   Line 5 "    " $line
                                                }                                           }
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null    
                                                }                                   }
                                        }                                   Line 0 ""
                                }                           }
                                ElseIf($PubItem.PublishFrom -eq "Group")                           If($HTML)
                                {                           {
                                        $cnt = -1                                   $rowdata = @()
                                        ForEach($Item in $PubItem.PublishFromGroup)                                   $columnHeaders = @("Override post-logon message",($Script:htmlsb),$Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString(),$htmlwhite)
                                    If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)
                                        {                                   {
                                                $cnt++                                           ForEach($line in $ThemeWindowsPostlogonMessage)
                                                    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                    
                                                If($cnt -eq 0)    
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null                                                   $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))
                                                }                                           }
                                    }
                                                Else    
                                    $msg = "Windows client/Messages"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                                                {                           {
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null                                   WriteWordLine 4 0 "Windows client/Custom menu"
                                                }                           }
                            If($Text)
                            {
                                    Line 2 "Windows client/Custom menu"
                                        }                           }
                            If($HTML)
                            {
                                    #Nothing
                                }                           }
                                Else                          
                            If($MSWord -or $PDF)
                                {                           {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Menu item"; Value = $Theme.WindowsClient.CustomMenu.MenuItem; }) > $Null
                                        $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Command"; Value = $Theme.WindowsClient.CustomMenu.Command; }) > $Null
                                }    
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  -+                         }
                            If($Text)
                            {
                                    Line 3 "Menu item: " $Theme.WindowsClient.CustomMenu.MenuItem
                                    Line 3 "Command`t : " $Theme.WindowsClient.CustomMenu.Command
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Menu item",($Script:htmlsb),$Theme.WindowsClient.CustomMenu.MenuItem,$htmlwhite)
                                    $rowdata += @(,("Command",($Script:htmlsb),$Theme.WindowsClient.CustomMenu.Command,$htmlwhite))
 
  <>                                 $msg = "Windows client/Custom menu"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
     
            #Certificates
     
            $Certs = Get-RASCertificate -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Certificates for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Certificates for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $Certs)
            {
                    Write-Host "
                    No Certificates retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Certificates retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Certificates retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Certificates retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    If($MSWord -or $PDF)
                    {
                                WriteWordLine 3 0 "Application"                           WriteWordLine 2 0 "Certificates"
                    }
                    If($Text)
                    {
                            Line 1 "Certificates"
                    }
                    If($HTML)
                    {
                                WriteWordLine 4 0 "Application"                           WriteHTMLLine 2 0 "Certificates"
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Certificates"
                    ForEach($Cert in $Certs)
                    {
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Certificate $($Cert.Name)"
 
                                $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Name"; Value = $Cert.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Status"; Value = $Cert.Status.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Expiration date"; Value = $Cert.ExpirationDate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Usage"; Value = $Cert.Usage; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Common name"; Value = $Cert.CommonName; }) > $Null
                                    
                                    $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Alternate Names"; Value = $Item; }) > $Null
                                            }
                                            Else
                                            {
                                $ScriptInformation.Add(@{Data = "Run"; Value = $WinType; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Cert.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $Cert.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $Cert.AdminCreate; }) > $Null
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Created on"; Value = $Cert.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "ID"; Value = $Cert.Id.ToString(); }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  -+                         }
                            If($Text)
                            {
                                    Line 2 "Certificate $($Cert.Name)"
                                    Line 3 "Name`t`t`t: " $Cert.Name
                                    Line 3 "Status`t`t`t: " $Cert.Status.ToString()
                                    Line 3 "Expiration date`t`t: " $Cert.ExpirationDate
                                    Line 3 "Usage`t`t`t: " $Cert.Usage
                                    Line 3 "Common name`t`t: " $Cert.CommonName
 
  <>                                 $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    Line 3 "Alternate Names`t`t: " $Item
                                            }
                                            Else
                                            {
                                                    Line 6 "  " $Item
                                            }
                                    }
                                    
                                    Line 3 "Last modification by`t: " $Cert.AdminLastMod
                                    Line 3 "Modified on`t`t: " $Cert.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t: " $Cert.AdminCreate
                                    Line 3 "Created on`t`t: " $Cert.TimeCreate.ToString()
                                    Line 3 "ID`t`t`t: " $Cert.Id.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $CertName = $Cert.Name.Replace("<","").Replace(">","")
                                    WriteHTMLLine 3 0 "Certificate $CertName"
                                    $rowdata = @()
                                    $columnHeaders = @("Name",($Script:htmlsb),$CertName,$htmlwhite)
                                    $rowdata += @(,("Status",($Script:htmlsb),$Cert.Status.ToString(),$htmlwhite))
                                    $rowdata += @(,("Expiration date",($Script:htmlsb),$Cert.ExpirationDate,$htmlwhite))
                                    $rowdata += @(,("Usage",($Script:htmlsb),$Cert.Usage,$htmlwhite))
                                    $rowdata += @(,("Common name",($Script:htmlsb),$Cert.CommonName,$htmlwhite))
                                    
                                    $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $rowdata += @(,("Alternate Names",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $Cert.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $Cert.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $Cert.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $Cert.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("ID",($Script:htmlsb),$Cert.Id.ToString(),$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                WriteWordLine 4 0 "Server settings"                                   WriteWordLine 4 0 "General"
                            }
                            If($Text)
                            {
                                    Line 2 "General"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            Switch($Cert.KeySize)
                            {
                                    "KeySize1024"           {$KeySize = "1024"; Break}
                                    "KeySize2048"           {$KeySize = "2048"; Break}
                                    "KeySize4096"           {$KeySize = "4096"; Break}
                                    "KeySizeUnknown"        {$KeySize = ""; Break}
                                    Default                         {$KeySize = "Unable to determine certificate key size: $($Cert.KeySize)"; Break}
                            }
                            
                            If($MSWord -or $PDF)
                            {
 
                                $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Name"; Value = $Cert.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $Cert.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Usage"; Value = $Cert.Usage; }) > $Null
                                $ScriptInformation.Add(@{Data = "Start in"; Value = $PubItem.StartIn; }) > $Null                                   $ScriptInformation.Add(@{Data = "State"; Value = $Cert.Status.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Key size"; Value = $KeySize; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Expiration date"; Value = $Cert.ExpirationDate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Common name"; Value = $Cert.CommonName; }) > $Null
                                    
                                    $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null                                                   $ScriptInformation.Add(@{Data = "Alternate Names"; Value = $Item; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Name`t`t`t: " $Cert.Name
                                    Line 3 "Description`t`t: " $Cert.Description
                                    Line 3 "Usage`t`t`t: " $Cert.Usage
                                    Line 3 "State`t`t`t: " $Cert.Status.ToString()
                                    Line 3 "Key size`t`t: " $KeySize
                                    Line 3 "Expiration date`t`t: " $Cert.ExpirationDate
                                    Line 3 "Common name`t`t: " $Cert.CommonName
                                    
                                    $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    Line 3 "Alternate Names`t`t: " $Item
                                            }
                                            Else
                                            {
                                                    Line 6 "  " $Item
                                            }
                                    }
                                    
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Name",($Script:htmlsb),$Cert.Name.Replace("<","").Replace(">",""),$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$Cert.Description,$htmlwhite))
                                    $rowdata += @(,("Usage",($Script:htmlsb),$Cert.Usage,$htmlwhite))
                                    $rowdata += @(,("State",($Script:htmlsb),$Cert.Status.ToString(),$htmlwhite))
                                    $rowdata += @(,("Key size",($Script:htmlsb),$KeySize,$htmlwhite))
                                    $rowdata += @(,("Expiration date",($Script:htmlsb),$Cert.ExpirationDate,$htmlwhite))
                                    $rowdata += @(,("Common name",($Script:htmlsb),$Cert.CommonName,$htmlwhite))
                                    
                                    $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $rowdata += @(,("Alternate Names",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    
                                    $msg = "General"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
     
            #Settings
            
            #Auditing - not in PoSH
     
            #Global logging - not in PoSH
     
            $FarmSettings = Get-RASFarmSettings -SiteId $Site.Id -ea 0 4>$Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Settings for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Settings for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Settings for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Settings for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $FarmSettings)
            {
                    Write-Host "
                    No Settings retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Settings retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Settings retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Settings retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "Settings"
                    }
                    If($Text)
                    {
                            Line 1 "Settings"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "Settings"
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Settings"
            }
            
            <#RASFarmSettings       
                    Dropped Properties      ExcludeDirectRDP
                                                            ExcludeDirectRDPForVDI
                                                            SendHDIcons
                                                            ReplicateSendHDIcons
                                                            EnableOverlayIcons
                                                            ShowPasswordExpiry
                                                            ReplicateURLRedirection
                                                            URLBlackList
                                                            TokenValidationTime
     
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "URL redirection"
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Do not redirect the following URLs"; Value = ""; }) > $Null
                    $cnt = -1
                    ForEach($Item in $FarmSettings.URLBlacklist)
                    {
                            $cnt++
                            
                            If($Cnt -eq 0)
                            {
                                    $ScriptInformation.Add(@{Data = "     Url"; Value = $Item; }) > $Null
                            }
                            Else
                            {
                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                            }
                    }
                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sitess"; Value = $FarmSettings.ReplicateURLRedirection.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                   -Columns Data,Value `
                                -List `                   -List `
                                -Format $wdTableGrid `                   -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                   -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                 $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 300;                   $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                 FindWordDocumentEnd
                                $Table = $Null                   $Table = $Null
                                WriteWordLine 0 0 ""                   WriteWordLine 0 0 ""
                                           }
                                OutputPubItemFilters $PubItem "MSWordPDF"           If($Text)
            {
                    Line 2 "URL redirection"
                    Line 3 "Do not redirect the following URLs`t: "
                    $cnt = -1
                    ForEach($Item in $FarmSettings.URLBlacklist)
                    {
                            $cnt++
                                                          
                                OutputPubItemShortcuts $PubItem "MSWordPDF" `                           If($Cnt -eq 0)
                                $DefaultCreateShortcutOnDesktop `                           {
                                $DefaultCreateShortcutInStartFolder `                                   Line 7 "     Url: " $Item
                                $DefaultStartPath `                           }
                                $DefaultCreateShortcutInStartUpFolder `                           Else
                                $DefaultReplicateShortcutSettings                           {
                                    Line 8 "  " $Item
                            }
                                WriteWordLine 3 0 "File extensions"                   }
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Associate File Extensions"; Value = $PubItem.EnableFileExtensions.ToString(); }) > $Null                   Line 3 "Settings are replicated to all Sites`t: " $FarmSettings.ReplicateURLRedirection.ToString()
                    Line 0 ""
            }
                                If($PubItem.EnableFileExtensions)           If($HTML)
                                {           {
                    WriteHTMLLine 3 0 "URL redirection"
                    $rowdata = @()
                    $columnHeaders = @("Do not redirect the following URLs",($Script:htmlsb),"",$htmlwhite)
                                        $cnt = -1                   $cnt = -1
                                        ForEach($Item in $PubItem.FileExtensions)                   ForEach($Item in $FarmSettings.URLBlacklist)
                                        {                   {
                                                $cnt++                           $cnt++
                                                                          
                                                If($cnt -eq 0)                           If($Cnt -eq 0)
                                                {                           {
                                    $rowdata += @(,("     URL",($Script:htmlsb),$Item,$htmlwhite))
                            }
                            Else
                            {
                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                            }
                    }
                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FarmSettings.ReplicateURLRedirection.ToString(),$htmlwhite))
     
                    $msg = ""
                    $columnWidths = @("200","275")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
     
                    WriteHTMLLine 0 0 ""
            }
            #>      
            $RASNotificationHandlers = Get-RASNotification -SiteId $Site.Id -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve notification handlers information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve notification handlers information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve notification handlers information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve notification handlers information"
                    }
            }
                                                        $ScriptInformation.Add(@{Data = "Extension"; Value = $Item; }) > $Null           ElseIf($? -and $null -eq $RASNotificationHandlers)
            {
                    Write-Host "
                    No notification handlers information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No notification handlers information was found"
                                                }                   }
                    If($Text)
                    {
                            Line 0 "No notification handlers information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No notification handlers information was found"
                    }
            }
                                                Else           Else
                                                {           {
                    OutputRASNotifications $RASNotificationHandlers
            }
            
            $RASNotificationScripts = Get-RASNotificationScript -SiteId $Site.Id -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve notification scripts information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve notification scripts information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve notification scripts information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve notification scripts information"
                    }
            }
            ElseIf($? -and $null -eq $RASNotificationScripts)
            {
                    Write-Host "
                    No notification scripts information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No notification scripts information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No notification scripts information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No notification scripts information was found"
                    }
            }
            Else
            {
                    OutputRASNotificationScripts $RASNotificationScripts
            }
            
            $RASClientSettings = Get-RASClientSettings -SiteId $Site.Id -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve CLient Settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve CLient Settings information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve CLient Settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve CLient Settings information"
                    }
            }
            ElseIf($? -and $null -eq $RASClientSettings)
            {
                    Write-Host "
                    No CLient Settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No CLient Settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No CLient Settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No CLient Settings information was found"
                    }
            }
            Else
            {
                    OutputRASClientSettings $RASClientSettings
            }
     
            $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id}
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve FSLogix Settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve FSLogix Settings information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve FSLogix Settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve FSLogix Settings information"
                    }
            }
            ElseIf($? -and $null -eq $FSLogixDeploymentSettings)
            {
                    Write-Host "
                    No FSLogix Settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No FSLogix Settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No FSLogix Settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No FSLogix Settings information was found"
                    }
            }
            Else
            {
                    Switch($FSLogixDeploymentSettings.InstallType)
                    {
                            "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}
                            "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}
                            "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}
                            "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}
                            Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}
                    }
                    
                    $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL
                    $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath
                    $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName
                    $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
                    
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 3 0 "Features"
                            WriteWordLine 4 0 "FSLogix"
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Deployment method"; Value = $FSLogixDeploymentSettingsDeploymentMethod; }) > $Null
                            If($FSLogixDeploymentSettings.InstallType -eq "Online")
                            {
                                                        $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                   $ScriptInformation.Add(@{Data = "URL"; Value = $FSLogixDeploymentSettingsInstallOnlineURL; }) > $Null
                                                }                           }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                            {
                                    $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsNetworkDrivePath; }) > $Null
                                        }                           }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                            {
                                    $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsInstallerFileName; }) > $Null
                                }                           }
                                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateFileExtensionSettings.ToString(); }) > $Null                           $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null
                            
                                $Table = AddWordTable -Hashtable $ScriptInformation `                           $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                           -Columns Data,Value `
                                -List `                           -List `
                                -Format $wdTableGrid `                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 300;                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                         FindWordDocumentEnd
                                $Table = $Null                           $Table = $Null
                                WriteWordLine 0 0 ""                           WriteWordLine 0 0 ""
                    }
                    If($Text)
                    {
                            Line 2 "Features"
                            Line 3 "FSLogix"
                            Line 4 "Deployment method`t`t`t`t`t: " $FSLogixDeploymentSettingsDeploymentMethod
                            If($FSLogixDeploymentSettings.InstallType -eq "Online")
                            {
                                    Line 4 "URL`t`t`t`t`t`t`t: " $FSLogixDeploymentSettingsInstallOnlineURL
                            }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                            {
                                    Line 11 ": " $FSLogixDeploymentSettingsNetworkDrivePath
                            }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                            {
                                    Line 11 ": " $FSLogixDeploymentSettingsInstallerFileName
                            }
                            Line 4 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 3 0 "Features"
                            $rowdata = @()
                            $columnHeaders = @("Deployment method",($Script:htmlsb),$FSLogixDeploymentSettingsDeploymentMethod,$htmlwhite)
                            If($FSLogixDeploymentSettings.InstallType -eq "Online")
                            {
                                    $rowdata += @(,("URL",($Script:htmlsb),$FSLogixDeploymentSettingsInstallOnlineURL,$htmlwhite))
                            }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                            {
                                    $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsNetworkDrivePath,$htmlwhite))
                            }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                            {
                                    $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsInstallerFileName,$htmlwhite))
                            }
                            $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))
                                            
                            $msg = "FSLogix"
                            $columnWidths = @("200","250")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                    }
            }
    }
    #endregion
 
  <> #region process load balancing
    Function ProcessLoadBalancing
    {
            Param([object]$Site)
            
            Write-Verbose "$(Get-Date -Format G): Processing Load Balancing"
            
            OutputLoadBalancingSectionPage
            
            Write-Verbose "$(Get-Date -Format G): `tProcessing Load Balancing"
            
            $results = Get-RASLBSettings -SiteId $Site.Id -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Load Balancing information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Load Balancing information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Load Balancing information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Load Balancing information"
                    }
            }
            ElseIf($? -and $null -eq $results)
            {
                    Write-Host "
                    No Load Balancing information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Load Balancing information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No Load Balancing information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Load Balancing information was found"
                    }
            }
            Else
            {
                    OutputRASLBSettings $results
            }
            
            $results = Get-RASCPUOptimizationSettings -SiteId $Site.Id -EA 0 4>$Null
            
            If(!($?))
            {
            Write-Warning "
            `n
            Unable to retrieve CPU Optimization information
            "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve CPU Optimization information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve CPU Optimization information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve CPU Optimization information"
                    }
            }
            ElseIf($? -and $null -eq $results)
            {
                    Write-Host "
                    No CPU Optimization information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No CPU Optimization information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No CPU Optimization information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No CPU Optimization information was found"
                    }
            }
            Else
            {
                    OutputCPUOptimizationSettings $results
            }
    }
     
    Function OutputLoadBalancingSectionPage
    {
            If($MSWord -or $PDF)
            {
                    $Script:Selection.InsertNewPage()
                                WriteWordLine 3 0 "License"                   WriteWordLine 1 0 "Load Balancing"
            }
            If($Text)
            {
                    Line 0 "Load Balancing"
            }
            If($HTML)
            {
                    WriteHTMLLine 1 0 "Load Balancing"
            }
    }
     
    Function OutputRASLBSettings
    {
            Param([object] $RASLBSettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Load Balancing"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Load Balancing"
            }
            If($Text)
            {
                    Line 1 "Load Balancing"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Load Balancing"
            }
            
            Switch ($RASLBSettings.Method)
            {
                    "ResourceBased" {$RASLBSettingsMethod = "Resource Based"; Break}
                    "RoundRobin"    {$RASLBSettingsMethod = "Round Robin"; Break}
                    Default                 {$RASLBSettingsMethod = "Unable to determine Load balancing method: $($RASLBSettings.Method)"; Break}
            }
            
            If($MSWord -or $PDF)
            {
                                $ScriptInformation = New-Object System.Collections.ArrayList                   $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Method"; Value = $RASLBSettingsMethod; }) > $Null
                    $ScriptInformation.Add(@{Data = "Counters"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     User Sessions"; Value = $RASLBSettings.SessionsCounter; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Memory"; Value = $RASLBSettings.MemoryCounter; }) > $Null
                    $ScriptInformation.Add(@{Data = "     CPU"; Value = $RASLBSettings.CPUCounter; }) > $Null
                    $ScriptInformation.Add(@{Data = "Reconnect to disconnected sessions"; Value = $RASLBSettings.ReconnectDisconnect; }) > $Null
                    $ScriptInformation.Add(@{Data = "Reconnect sessions using client's IP address only"; Value = $RASLBSettings.ReconnectUsingIPOnly; }) > $Null
                    $ScriptInformation.Add(@{Data = "Limit each user to one session per desktop"; Value = $RASLBSettings.ReconnectUser; }) > $Null
                    $ScriptInformation.Add(@{Data = "Disable Microsoft RD Connection Broker"; Value = $RASLBSettings.DisableRDSLB; }) > $Null
                    $ScriptInformation.Add(@{Data = "Declare Agent dead if not responding for"; Value = "$($RASLBSettings.DeadTimeout) seconds"; }) > $Null
                    $ScriptInformation.Add(@{Data = "Agent Refresh Time"; Value = "$($RASLBSettings.RefreshTimeout) seconds"; }) > $Null
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $PubItem.InheritLicenseDefaultSettings.ToString(); }) > $Null                   $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASLBSettings.Replicate.ToString(); }) > $Null
 
  <>                 $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 275;
                    $Table.Columns.Item(2).Width = 150;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 2 "Method`t`t`t: " $RASLBSettingsMethod
                    Line 2 "Counters"
                    Line 3 "User Sessions`t: " $RASLBSettings.SessionsCounter
                    Line 3 "Memory`t`t: " $RASLBSettings.MemoryCounter
                    Line 3 "CPU`t`t: " $RASLBSettings.CPUCounter
                    Line 2 "Reconnect to disconnected sessions`t`t`t: " $RASLBSettings.ReconnectDisconnect
                    Line 2 "Reconnect sessions using client's IP address only`t: " $RASLBSettings.ReconnectUsingIPOnly
                    Line 2 "Limit each user to one session per desktop`t`t: " $RASLBSettings.ReconnectUser
                    Line 2 "Disable Microsoft RD Connection Broker`t`t`t: " $RASLBSettings.DisableRDSLB
                    Line 2 "Declare Agent dead if not responding for`t`t: " "$($RASLBSettings.DeadTimeout) seconds"
                    Line 2 "Agent Refresh Time`t`t`t`t`t: " "$($RASLBSettings.RefreshTimeout) seconds"
                    Line 2 "Settings are replicated to all Sites`t`t`t: " $RASLBSettings.Replicate.ToString()
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @("Method",($Script:htmlsb),$RASLBSettingsMethod,$htmlwhite)
                    $rowdata += @(,("Counters",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("     User Sessions",($Script:htmlsb),$RASLBSettings.SessionsCounter.ToString(),$htmlwhite))
                    $rowdata += @(,("     Memory",($Script:htmlsb),$RASLBSettings.MemoryCounter.ToString(),$htmlwhite))
                    $rowdata += @(,("     CPU",($Script:htmlsb),$RASLBSettings.CPUCounter.ToString(),$htmlwhite))
                    $rowdata += @(,("Reconnect to disconnected sessions",($Script:htmlsb),$RASLBSettings.ReconnectDisconnect.ToString(),$htmlwhite))
                    $rowdata += @(,("Reconnect sessions using client's IP address only",($Script:htmlsb),$RASLBSettings.ReconnectUsingIPOnly.ToString(),$htmlwhite))
                    $rowdata += @(,("Limit each user to one session per desktop",($Script:htmlsb),$RASLBSettings.ReconnectUser.ToString(),$htmlwhite))
                    $rowdata += @(,("Disable Microsoft RD Connection Broker",($Script:htmlsb),$RASLBSettings.DisableRDSLB.ToString(),$htmlwhite))
                    $rowdata += @(,("Declare Agent dead if not responding for",($Script:htmlsb),"$($RASLBSettings.DeadTimeout) seconds",$htmlwhite))
                    $rowdata += @(,("Agent Refresh Time",($Script:htmlsb),"$($RASLBSettings.RefreshTimeout) seconds",$htmlwhite))
                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASLBSettings.Replicate.ToString(),$htmlwhite))
     
                    $msg = ""
                    $columnWidths = @("300","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
     
    Function OutputCPUOptimizationSettings
    {
            Param([object] $RASCPUSettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput CPU Optimization"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "CPU Optimization"
            }
            If($Text)
            {
                    Line 1 "CPU Optimization"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "CPU Optimization"
            }
            
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Enable CPU Optimization"; Value = $RASCPUSettings.EnableCPUOptimization.ToString(); }) > $Null
                    $ScriptInformation.Add(@{Data = "Start"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Total CPU usage exceeds"; Value = "$($RASCPUSettings.StartUsage) %"; }) > $Null
                    $ScriptInformation.Add(@{Data = "CPU Conditions"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Critical - CPU usage by process exceeds"; Value = "$($RASCPUSettings.CriticalUsage) %"; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Idle - CPU usage by process exceeds"; Value = "$($RASCPUSettings.IdleUsage) %"; }) > $Null
                    $ScriptInformation.Add(@{Data = "Exclusions"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Processes that will be excluded from CPU Optimization"; Value = ""; }) > $Null
                    
                    If($RASCPUSettings.CPUExcludeList.Count -eq 0)
                    {
                            $ScriptInformation.Add(@{Data = "          Processes to exclude"; Value = "None"; }) > $Null
                    }
                    Else
                    {
                            $cnt = -1
                            
                                If($PubItem.InheritLicenseDefaultSettings)                           ForEach($item in $RASCPUSettings.CPUExcludeList)
                            {
                                    $cnt++
                                    
                                    If($cnt -eq 0)
 
  <>                                         $ScriptInformation.Add(@{Data = "          Processes to exclude"; Value = $item; }) > $Null
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                    }
                            }
                    }
     
                                        $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $DefaultDisableSessionSharing ; }) > $Null                   $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASCPUSettings.Replicate.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 275;
                    $Table.Columns.Item(2).Width = 150;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 2 "Enable CPU Optimization`t`t`t`t`t: " $RASCPUSettings.EnableCPUOptimization.ToString()
                    Line 2 "Start"
                    Line 3 "Total CPU usage exceeds`t`t`t`t: " "$($RASCPUSettings.StartUsage) %"
                    Line 2 "CPU Conditions"
                    Line 3 "Critical - CPU usage by process exceeds`t`t: " "$($RASCPUSettings.CriticalUsage) %"
                    Line 3 "Idle - CPU usage by process exceeds`t`t: " "$($RASCPUSettings.IdleUsage) %"
                    Line 2 "Exclusions"
                    Line 3 "Processes that will be excluded from CPU Optimization"
                    
                    If($RASCPUSettings.CPUExcludeList.Count -eq 0)
                    {
                            Line 4 "Processes to exclude`t`t`t: None"
                    }
                    Else
                    {
                            $cnt = -1
                            
                            ForEach($item in $RASCPUSettings.CPUExcludeList)
                            {
                                    $cnt++
                                    
                                    If($cnt -eq 0)
                                    {
                                            Line 4 "Processes to exclude`t`t`t: " $item
                                    }
                                    Else
                                    {
                                            Line 9 "  " $item
                                    }
                            }
                    }
     
                    Line 2 "Settings are replicated to all Sites`t`t`t: " $RASCPUSettings.Replicate.ToString()
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @("Enable CPU Optimization",($Script:htmlsb),$RASCPUSettings.EnableCPUOptimization.ToString(),$htmlwhite)
                    $rowdata += @(,("Start",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("     Total CPU usage exceeds",($Script:htmlsb),"$($RASCPUSettings.StartUsage) %",$htmlwhite))
                    $rowdata += @(,("CPU Conditions",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("     Critical - CPU usage by process exceeds",($Script:htmlsb),"$($RASCPUSettings.CriticalUsage) %",$htmlwhite))
                    $rowdata += @(,("     Idle - CPU usage by process exceeds",($Script:htmlsb),"$($RASCPUSettings.IdleUsage) %",$htmlwhite))
                    $rowdata += @(,("Exclusions",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("     Processes that will be excluded from CPU Optimization",($Script:htmlsb),"",$htmlwhite))
                    
                    If($RASCPUSettings.CPUExcludeList.Count -eq 0)
                    {
                            $rowdata += @(,("          Processes to exclude",($Script:htmlsb),"None",$htmlwhite))
                    }
                    Else
                    {
                            $cnt = -1
                            
                            ForEach($item in $RASCPUSettings.CPUExcludeList)
                            {
                                    $cnt++
                                    
                                    If($cnt -eq 0)
                                    {
                                            $rowdata += @(,("          Processes to exclude",($Script:htmlsb),$item,$htmlwhite))
                                    }
                                    Else
                                    {
                                            $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))
                                    }
                            }
                    }
     
                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASCPUSettings.Replicate.ToString(),$htmlwhite))
                    $msg = ""
                    $columnWidths = @("300","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
    #endregion
     
    #region process publishing
    Function ListFolder($folder, $spaces) 
    {
            #function provided 23-July-2020 by Ian Sant of Parallels
            #list published items in the order they appear in the console
            #modified 24-July-2020 by Webster to make it work with this script
            $prevId = 0
     
            Do
            {
                    $item = $Script:AllItems | Where-Object {($_.ParentId -eq $folder) -and ($_.PreviousId -eq $prevId)}
                    If ($Null -eq $item) {
                            Return
                    }
     
                    #Write-Host $spaces $item.Name
                    $Script:OrderedItems.Add($item) >$Null
                    If ($item.Type -eq "Folder") {
                            $newspaces = $spaces + "   "
                            ListFolder $item.Id $newspaces
                    }
                    $prevId = $item.Id
            } While ($true) 
    }
     
    Function ProcessPublishing
    {
            Param([object]$Site)
            
            Write-Verbose "$(Get-Date -Format G): Processing Publishing"
            
            OutputPublishingSectionPage $Site.Name
                            
            Write-Verbose "$(Get-Date -Format G): `tProcessing Publishing"
            
            $results = Get-RASPubItem -SiteId $Site.Id -EA 0 4>$Null
                    
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Publishing information for Site $($Site.Name)
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Publishing information for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Publishing information for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Publishing information for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $null -eq $results)
            {
                    Write-Host "
                    No Publishing information was found for Site $($Site.Name)
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "No Publishing information was found for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Publishing information was found for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "No Publishing information was found for Site $($Site.Name)"
                    }
            }
            Else
            {
                    $Script:OrderedItems = New-Object System.Collections.ArrayList
                    $Script:AllItems = $results
                    ListFolder 0 ""
                    OutputPublishingSettings $Script:OrderedItems $Site.Id $Site.Name
            }
    }
     
    Function OutputPublishingSectionPage
    {
            Param([string] $SiteName)
            
            If($MSWord -or $PDF)
            {
                    $Script:Selection.InsertNewPage()
                    WriteWordLine 1 0 "Publishing for Site $($SiteName)"
            }
            If($Text)
            {
                    Line 0 "Publishing for Site $($SiteName)"
            }
            If($HTML)
            {
                    WriteHTMLLine 1 0 "Publishing for Site $($SiteName)"
            }
    }
     
    Function OutputPublishingSettings
    {
            Param([object] $PubItems, [uint32] $SiteId, [string] $xSiteName)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Publishing"
            
            <#
            Folder
            PCApp
            PCDesktop
            RDSApp
            RDSDesktop
            VDIApp
            VDIDesktop
            WVDApp
            WVDDesktop
            #>
     
            #Get the published items default settings
            Write-Verbose "$(Get-Date -Format G): `t`t`tRetrieve Publishing Default Site Settings for Site $xSiteName"
            $results = Get-RASPubDefaultSettings -SiteId $SiteId -EA 0 4>$Null
            
            If(!$?)
            {
                    Write-Host "
                    Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults
                    " -ForegroundColor White
                    <#
                    StartPath                     : RAS Remote Desktops & Applications\%Groups%
                    CreateShortcutOnDesktop       : False
                    CreateShortcutInStartFolder   : True
                    CreateShortcutInStartUpFolder : False
                    ReplicateShortcutSettings     : False
                    ReplicateDisplaySettings      : False
                    WaitForPrinters               : False
                    StartMaximized                : True
                    WaitForPrintersTimeout        : 20
                    ColorDepth                    : ClientSpecified
                    DisableSessionSharing         : False
                    OneInstancePerUser            : False
                    ConCurrentLicenses            : 0
                    LicenseLimitNotify            : WarnUserAndNoStart
                    ReplicateLicenseSettings      : False
                    #>
                    
                    #Shortcuts tab
                    $DefaultCreateShortcutOnDesktop       = "False"
                    $DefaultCreateShortcutInStartFolder   = "True"
                    $DefaultStartPath                     = "RAS Remote Desktops & Applications\%Groups%"
                    $DefaultCreateShortcutInStartUpFolder = "False"
                    $DefaultReplicateShortcutSettings     = "False"
                    
                    #License tab
                    $DefaultDisableSessionSharing         = "False"
                                        If($DefaultOneInstancePerUser)                   $DefaultOneInstancePerUser            = "False"
                    $DefaultConCurrentLicenses            = "Unlimited"
                    $DefaultLicenseLimitNotify            = "Warn user and do not start"
                    $DefaultReplicateLicenseSettings      = "False"
     
                    #Display tab
                    $DefaultWaitForPrinters               = "False"
                    $DefaultWaitForPrintersTimeout        = "20"
                    $DefaultColorDepth                    = "Client Specified"
                    $DefaultStartMaximized                = "True"
                    $DefaultReplicateDisplaySettings      = "False"
     
                    If($MSWord -or $PDF)
                                        {                   {
                            WriteWordLine 0 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"
                    }
            }
            Else
            {
                    #Shortcuts tab
                    $DefaultCreateShortcutOnDesktop       = $results.CreateShortcutOnDesktop.ToString()      
                    $DefaultCreateShortcutInStartFolder   = $results.CreateShortcutInStartFolder.ToString()
                    $DefaultStartPath                     = $results.StartPath                    
                    $DefaultCreateShortcutInStartUpFolder = $results.CreateShortcutInStartUpFolder.ToString()
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null                   $DefaultReplicateShortcutSetting    = $results.ReplicateShortcutSettings.ToString()
     
                    #License tab
                    $DefaultDisableSessionSharing         = $results.DisableSessionSharing.ToString()    
                    $DefaultOneInstancePerUser            = $results.OneInstancePerUser.ToString()
                    If($results.ConCurrentLicenses -eq 0)
                    {
                            $DefaultConCurrentLicenses        = "Unlimited"
                                        }                   }
                                        Else                   Else
                                        {                   {
                            $DefaultConCurrentLicenses        = $results.ConCurrentLicenses.ToString()    
                    }
                     
                    Switch ($results.LicenseLimitNotify)
                    {
                            "WarnUserAndNoStart"            {$DefaultLicenseLimitNotify = "Warn user and do not start"; Break}
                            "WarnUserAndStart"                      {$DefaultLicenseLimitNotify = "Warn user and start"; Break}
                            "NotifyAdminAndStart"           {$DefaultLicenseLimitNotify = "Notify administrator and start"; Break}
                            "NotifyUserAdminAndStart"       {$DefaultLicenseLimitNotify = "Notify user, administrator and start"; Break}
                            "NotifyUserAdminAndNoStart"     {$DefaultLicenseLimitNotify = "Notify user, administrator and do not start"; Break}
                            Default                                         {$DefaultLicenseLimitNotify = "Unable to determine If limit is eceeded: $($results.LicenseLimitNotify)"; Break}
                    }
                    
                    $DefaultReplicateLicenseSettings      = $results.ReplicateLicenseSettings.ToString()
     
                    #Display tab
                    $DefaultWaitForPrinters               = $results.WaitForPrinters.ToString()
                    $DefaultWaitForPrintersTimeout        = $results.WaitForPrintersTimeout.ToString()
                    Switch ($results.ColorDepth)
                    {
                            "Colors8Bit"            {$DefaultColorDepth = "256 Colors"; Break}
                            "Colors15Bit"           {$DefaultColorDepth = "High Color (15 bit)"; Break}
                            "Colors16Bit"           {$DefaultColorDepth = "High Color (16 bit)"; Break}
                            "Colors24Bit"           {$DefaultColorDepth = "True Color (24 bit)"; Break}
                            "Colors32Bit"           {$DefaultColorDepth = "Highest Quality (32 bit)"; Break}
                            "ClientSpecified"       {$DefaultColorDepth = "Client Specified"; Break}
                            Default                         {$DefaultColorDepth = "Unable to determine Color Depth: $($PubItem.ColorDepth)"; Break}
                    }
                    $DefaultStartMaximized                = $results.StartMaximized.ToString()   
                    $DefaultReplicateDisplaySettings      = $results.ReplicateDisplaySettings.ToString()
            }
            
            ForEach($PubItem in $PubItems)
            {
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tOutput $($PubItem.Name)"
     
                    If(ValidObject $PubItem WinType)
                    {
                            Switch ($PubItem.WinType)
                            {
                                    "Normal"        {$WinType = "Normal Window"; Break}
                                    "Maximized"     {$WinType = "Maximized"; Break}
                                    "Minimized"     {$WinType = "Minimized"; Break}
                                    Default         {$WinType = "Unable to determine window Run type: $($PubItem.WinType)"; Break}
                            }
                    }
     
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 $PubItem.Name
                    }
                    If($Text)
                    {
                            Line 1 $PubItem.Name
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 $PubItem.Name
                    }
            
                    If($PubItem.Type -eq "Folder")
                    {
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Information"
                            }
                            If($Text)
                            {
                                    Line 2 "Information"
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 3 0 "Information"
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Folder"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null
                                    
                                    If($PubItem.AdminOnly -eq $True)
                                    {
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Use for administrative purposes"; Value = ""; }) > $Null
                                        }                                   }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                        $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $DefaultConCurrentLicenses; }) > $Null                                           $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                        $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $DefaultLicenseLimitNotify; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null
                                            }
 
  <>                                 If($PubItem.IPFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                Else                                                           Else
                                {                                                           {
                                        $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $SessionSharing; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                        If($PubItem.OneInstancePerUser)                                                   ForEach($item in $PubItem.AllowedIP6s)
                                        {                                                   {
                                                            If($item.From -eq $item.To)
                                                            {
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                        }                                                           }
                                        Else                                                           Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedClients)
 
  <>                                                 $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null                                           $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
 
  <>                                 }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                        $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $ConCurrentLicenses; }) > $Null                                           $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebClient)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null
                                            }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                        $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $LicenseLimitNotify; }) > $Null                                                   $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
 
  <>  
                                If($PubItem.InheritLicenseDefaultSettings)                                   If($PubItem.PreferredRoutingEnabled)
 
  <>                                         $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null
                                            
                                            If($? -and $Null -ne $Results)
                                            {
                                                    $cnt =-1
                                                    ForEach($PrefRoute in $Results)
                                                    {
                                                            $CustomRoute = Get-RASCustomRoute -Id $PrefRoute.Id -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $CustomRoute)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $DefaultReplicateLicenseSettings.ToString(); }) > $Null                                                                           $ScriptInformation.Add(@{Data = "Preferred routing is enabled"; Value = ""; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"; }) > $Null
                                }                                                                   }
                                Else                                                                   Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"; }) > $Null
                                                                    }
                                                            }
                                                    }
                                            }
                                    }
                    
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Sites"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
 
  <>                                         $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateLicenseSettings.ToString(); }) > $Null                                                   $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
 
                                WriteWordLine 3 0 "Display" <>                                 WriteWordLine 3 0 "Folder"
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $PubItem.InheritDisplayDefaultSettings.ToString(); }) > $Null <>  
     
                                If($PubItem.InheritDisplayDefaultSettings)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Wait until all RAS Universal Printers are redirected before showing the application"; Value = $DefaultWaitForPrinters; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Maximum time to wait is"; Value = "$($DefaultWaitForPrintersTimeout) seconds"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Color Depth"; Value = $DefaultColorDepth; }) > $Null                                   $ScriptInformation.Add(@{Data = "Folder Name"; Value = $PubItem.Name; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Start the application as maximized when using mobile clients"; Value = $DefaultStartMaximized; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Wait until all RAS Universal Printers are redirected before showing the application"; Value = $PubItem.WaitForPrinters.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Maximum time to wait is"; Value = "$($PubItem.WaitForPrintersTimeout.ToString()) seconds"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Color Depth"; Value = $ColorDepth; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Start the application as maximized when using mobile clients"; Value = $PubItem.StartMaximized.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Use for administrative purposes"; Value = $PubItem.AdminOnly.ToString(); }) > $Null
                                }    
                                If($PubItem.InheritDisplayDefaultSettings)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $DefaultReplicateDisplaySettings.ToString(); }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateDisplaySettings.ToString(); }) > $Null    
                                }    
 
  +-  
 
  -+  
                                    OutputPubItemFilters $PubItem "MSWordPDF"
 
                                Line 2 "Information" <>  
                                Line 3 "Application`t`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"                                   Line 3 "Folder`t`t`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
 
                                Line 3 "Status`t`t`t`t`t`t`t: " $PubItemMode +-  
                                Line 3 "Target`t`t`t`t`t`t`t: " $PubItem.Target    
                                Line 3 "Start In`t`t`t`t`t`t: " $PubItem.StartIn    
                                Line 3 "Start automatically when user logs on`t`t`t: " $PubItem.StartOnLogon.ToString()    
 
                                If(![String]::IsNullOrEmpty($PubItem.Parameters)) <>  
                                {    
                                        Line 3 "Parameters`t`t`t`t`t`t: " $PubItem.Parameters    
                                }    
                                    
                                If($PubItem.EnableFileExtensions)    
                                {    
                                        Line 3 "Associate the following file extensions"    
                                        ForEach($Item in $PubItem.FileExtensions)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                }    
                                    
                                If($PubItem.InheritLicenseDefaultSettings)    
                                {    
                                        Line 3 "Allow users to start only 1 instance of this application: " $DefaultOneInstancePerUser.ToString()    
                                        Line 3 "Concurrent licenses`t`t`t`t`t: " $DefaultConCurrentLicenses    
                                        Line 3 "If limit is exceeded`t`t`t`t`t: " $DefaultLicenseLimitNotify    
                                        Line 3 "Session Sharing`t`t`t`t`t`t: " $DefaultDisableSessionSharing     
                                }    
                                Else    
                                {    
                                        Line 3 "Allow users to start only 1 instance of this application: " $PubItem.OneInstancePerUser.ToString()    
                                        Line 3 "Concurrent licenses`t`t`t`t`t: " $ConCurrentLicenses    
                                        Line 3 "If limit is exceeded`t`t`t`t`t: " $LicenseLimitNotify    
                                        Line 3 "Session Sharing`t`t`t`t`t`t: " $SessionSharing    
                                }    
     
                                Line 3 "Settings for Site $xSiteName"    
                                    
                                If($PubItem.PublishFrom -eq "Server")                                   If($PubItem.AdminOnly -eq $True)
 
                                        $cnt = -1 <>  
                                        ForEach($Item in $PubItem.PublishFromServer)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 3 "Published from`t`t`t`t`t`t: " ItemName    
                                                }    
                                                Else    
                                                {    
                                                        Line 10 $ItemName    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 3 "Published from`t`t`t`t`t`t: " ItemName    
                                                }    
                                                Else    
                                                {    
                                                        Line 10 $ItemName    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        Line 3 "Published from`t`t`t`t`t`t: " "All Servers in Site"    
                                }    
     
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                Line 3 "Create shortcut on desktop"                                           Line 3 "Use for administrative purposes"
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"    
                                        }    
 
                                Else +-  
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                Line 3 "Create shortcut on desktop"    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"    
                                        }    
                                }    
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
                                Line 0 "" +-  
 
                                Line 2 "Sites" <>  
                                Line 3 "This published item will be available from the following Sites"    
                                ForEach($Site in $PubItem.PublishToSite)                                   If($PubItem.PreferredRoutingEnabled)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name <>                                         $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null
 
                                        Line 10 $SiteName <>                                         If($? -and $Null -ne $Results)
                                }    
                                Line 0 ""    
     
                                Line 2 "Publish from"    
                                Line 3 $PublishedFrom    
                                If($PubItem.PublishFrom -eq "Server")    
                                {    
                                        ForEach($Item in $PubItem.PublishFromServer)    
 
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server <>  
                                                Line 6 $ItemName    
                                        }                                                   $cnt =-1
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        ForEach($Item in $PubItem.PublishFromGroup)                                                   ForEach($PrefRoute in $Results)
                                        {                                                   {
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name                                                           $CustomRoute = Get-RASCustomRoute -Id $PrefRoute.Id -EA 0 4>$Null
                                                Line 5 $ItemName    
                                        }    
                                }    
                                Line 0 ""    
     
                                Line 2 "Application"    
                                Line 3 "Application"    
                                Line 4 "Name`t`t`t`t`t`t":  $PubItem.Name    
                                Line 4 "Description`t`t`t`t`t: " $PubItem.Description    
                                Line 4 "Run`t`t`t`t`t`t: " $WinType    
                                Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()    
                                Line 0 ""    
                                                                                          
                                Line 3 "Server settings"    
                                Line 4 "Target`t`t`t`t`t`t: " $PubItem.Target    
                                Line 4 "Start in`t`t`t`t`t: " $PubItem.StartIn    
                                Line 4 "Parameters`t`t`t`t`t: " $PubItem.Parameters    
                                Line 0 ""    
                                    
                                OutputPubItemFilters $PubItem "Text"    
                                    
                                OutputPubItemShortcuts $PubItem "Text" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
     
                                Line 2 "File extensions"    
                                Line 3 "Associate File Extensions`t`t`t`t: " $PubItem.EnableFileExtensions.ToString()    
     
                                If($PubItem.EnableFileExtensions)                                                           If($? -and $Null -ne $CustomRoute)
                                {                                                           {
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.FileExtensions)    
                                        {    
                                                $cnt++                                                                   $cnt++
                                                If($cnt -eq 0 )                                                                   If($cnt -eq 0)
                                                {                                                                   {
                                                        Line 8 "Extension`t: " $Item                                                                           Line 3 "Preferred routing is enabled"
                                                                            Line 7 "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"
                                                }                                                                   }
                                                Else                                                                   Else
                                                {                                                                   {
                                                        Line 10" $Item                                                                           Line 7 "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"
                                                                    }
                                                            }
 
                                Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateFileExtensionSettings.ToString() +-  
 
                                Line 2 "License" <>                                 Line 2 Sites
                                Line 3 "Inherit default settings`t`t`t`t: " $PubItem.InheritLicenseDefaultSettings.ToString()    
                                    $cnt =-1
                                If($PubItem.InheritLicenseDefaultSettings)                                   ForEach($Site in $PubItem.PublishToSite)
 
                                        Line 3 "Session Sharing`t`t`t`t`t`t: " $DefaultDisableSessionSharing <>  
                                        Line 3 "Allow users to start only 1 instance of this application: " $DefaultOneInstancePerUser.ToString()    
                                        Line 3 "Concurrent licenses`t`t`t`t`t: " $DefaultConCurrentLicenses    
                                        Line 3 "If limit is exceeded`t`t`t`t`t: " $DefaultLicenseLimitNotify    
                                }                                           $cnt++
                                Else                                           $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                {    
                                        Line 3 "Session Sharing`t`t`t`t`t`t: " $SessionSharing    
                                        Line 3 "Allow users to start only 1 instance of this application: " $PubItem.OneInstancePerUser.ToString()    
                                        Line 3 "Concurrent licenses`t`t`t`t`t: " $ConCurrentLicenses    
                                        Line 3 "If limit is exceeded`t`t`t`t`t: " $LicenseLimitNotify    
                                }    
                                            
                                If($PubItem.InheritLicenseDefaultSettings)                                           If($cnt -eq 0)
                                {                                           {
                                        Line 3 "Settings are replicated to all Sites`t`t`t: " $DefaultReplicateLicenseSettings.ToString()                                                   Line 3 "This published item will be available from the following Sites: " $SiteName
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateLicenseSettings.ToString()                                                   Line 10 "  " $SiteName
                                }                                           }
                                Line 0 ""    
     
                                Line 2 "Display"    
                                Line 3 "Inherit default settings`t`t`t`t: " $PubItem.InheritDisplayDefaultSettings.ToString()    
     
                                If($PubItem.InheritDisplayDefaultSettings)    
                                {    
                                        Line 3 "Wait until all RAS Universal Printers are redirected "    
                                        Line 3 "before showing the application`t`t`t`t: " $DefaultWaitForPrinters    
                                        Line 3 "Maximum time to wait is`t`t`t`t`t: " "$($DefaultWaitForPrintersTimeout) seconds"    
                                        Line 3 "Color Depth`t`t`t`t`t`t: " $DefaultColorDepth    
                                        Line 3 "Start the application as maximized "    
                                        Line 3 "when using mobile clients`t`t`t`t: " $DefaultStartMaximized    
 
                                Else <>  
                                {                                  
                                        Line 3 "Wait until all RAS Universal Printers are redirected "                                   Line 2 "Folder"
                                        Line 3 "before showing the application`t`t`t`t: " $PubItem.WaitForPrinters.ToString()    
                                        Line 3 "Maximum time to wait is`t`t`t`t`t: " "$($PubItem.WaitForPrintersTimeout.ToString()) seconds"    
                                        Line 3 "Color Depth`t`t`t`t`t`t: " $ColorDepth                                   Line 3 "Folder Name`t`t`t`t`t`t: " $PubItem.Name
                                        Line 3 "Start the application as maximized "    
                                        Line 3 "when using mobile clients`t`t`t`t: " $PubItem.StartMaximized.ToString()                                   Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description
                                }    
     
                                Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateDisplaySettings.ToString()                                   Line 3 "Use for administrative purposest`t`t`t: " $PubItem.AdminOnly.ToString()
 
  -+                                 
                                    OutputPubItemFilters $PubItem "Text"
 
                                WriteHTMLLine 3 0 "Information" +-  
 
                                $columnHeaders = @("Application",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite) <>                                 $columnHeaders = @("Folder",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
 
                                $rowdata += @(,("Status",($Script:htmlsb),$PubItemMode,$htmlwhite)) +-  
                                $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))    
                                $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))    
 
                                If(![String]::IsNullOrEmpty($PubItem.Parameters)) <>  
                                {    
                                        $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))    
                                }    
                                    
                                If($PubItem.EnableFileExtensions)    
                                {    
                                        $rowdata += @(,("Associate the following file extensions",($Script:htmlsb),"",$htmlwhite))    
                                        ForEach($Item in $PubItem.FileExtensions)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                    
                                If($PubItem.InheritLicenseDefaultSettings)    
                                {    
                                        If($DefaultOneInstancePerUser)    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))    
                                        }    
                                        $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$DefaultConCurrentLicenses,$htmlwhite))    
                                        $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$DefaultLicenseLimitNotify,$htmlwhite))    
                                        $rowdata += @(,("Session Sharing",($Script:htmlsb),$DefaultDisableSessionSharing,$htmlwhite))    
                                }    
                                Else    
                                {    
                                        If($PubItem.OneInstancePerUser)    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))    
                                        }    
                                        $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$ConCurrentLicenses,$htmlwhite))    
                                        $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$LicenseLimitNotify,$htmlwhite))    
                                        $rowdata += @(,("Session Sharing",($Script:htmlsb),$SessionSharing,$htmlwhite))    
                                }    
     
                                $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))    
                                    
                                If($PubItem.PublishFrom -eq "Server")                                   If($PubItem.AdminOnly -eq $True)
 
                                        $cnt = -1 <>  
                                        ForEach($Item in $PubItem.PublishFromServer)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Published from",($Script:htmlsb),"All Servers in Site",$htmlwhite))                                           $rowdata += @(,("Use for administrative purposes",($Script:htmlsb), "",$htmlwhite))
 
                                If($PubItem.InheritShortcutDefaultSettings) +-  
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
     
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
                         +-  
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
 
                                WriteHTMLLine 3 0 "Sites" <>  
                                $rowdata = @()    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)                                   If($PubItem.PreferredRoutingEnabled)
 
                                        $cnt++ <>  
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name                                           $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null
 
                                        If($cnt -eq 0) <>                                         If($? -and $Null -ne $Results)
 
                                                $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite) <>  
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Publish from"    
                                $rowdata = @()    
                                If($PubItem.PublishFrom -eq "Server")    
                                {    
                                        $cnt = -1                                                   $cnt =-1
                                        ForEach($Item in $PubItem.PublishFromServer)                                                   ForEach($PrefRoute in $Results)
                                        {                                                   {
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server                                                           $CustomRoute = Get-RASCustomRoute -Id $PrefRoute.Id -EA 0 4>$Null
                                                                                                          
                                                If($cnt -eq 0)                                                           If($? -and $Null -ne $CustomRoute)
                                                {                                                           {
                                                        $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++                                                                   $cnt++
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                    
                                                If($cnt -eq 0)                                                                   If($cnt -eq 0)
                                                {                                                                   {
                                                        $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)                                                                           $rowdata += @(,("Preferred routing is enabled",($Script:htmlsb),"",$htmlwhite))
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))                                                                           $rowdata += @(,("",($Script:htmlsb),"$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)",$htmlwhite))
                                                }                                                                   }
                                        }    
                                }    
                                Else                                                                   Else
                                {                                                                   {
                                        $columnHeaders = @("$PublishedFrom",($Script:htmlsb),"",$htmlwhite)                                                                           $rowdata += @(,("",($Script:htmlsb),"$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)",$htmlwhite))
                                }                                                                   }
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Application"    
                                $rowdata = @()    
     
                                $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Run",($Script:htmlsb),$WinType,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))    
     
                                $msg = "Application"    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                                    
                                $rowdata = @()    
                                $columnHeaders = @("Server(s)",($Script:htmlsb),"",$htmlwhite)    
                                $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))    
                                $rowdata += @(,("Start in",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))    
                                $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))    
     
                                $msg = "Server settings"    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                OutputPubItemFilters $PubItem "HTML"    
                                    
                                OutputPubItemShortcuts $PubItem "HTML" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
     
                                WriteHTMLLine 3 0 "File extensions"    
                                $rowdata = @()    
                                $columnHeaders = @("Associate File Extensions",($Script:htmlsb),$PubItem.EnableFileExtensions.ToString(),$htmlwhite)    
                                    
                                If($PubItem.EnableFileExtensions)    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.FileExtensions)    
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Extension",($Script:htmlsb),$Item,$htmlwhite))    
                                                }                                                           }
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
 
                                $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateFileExtensionSettings.ToString(),$htmlwhite)) +-  
     
 
  +-  
 
                                WriteHTMLLine 3 0 "License" <>                                 WriteHTMLLine 3 0 "Folder"
 
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$PubItem.InheritLicenseDefaultSettings.ToString(),$htmlwhite) +-  
 
                                If($PubItem.InheritLicenseDefaultSettings) <>  
                                {    
                                        $rowdata += @(,("Session Sharing",($Script:htmlsb),$DefaultDisableSessionSharing,$htmlwhite))    
                                        If($DefaultOneInstancePerUser)    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))    
                                        }    
                                        $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$DefaultConCurrentLicenses,$htmlwhite))    
                                        $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$DefaultLicenseLimitNotify,$htmlwhite))                                   $columnHeaders = @("Folder",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Session Sharing",($Script:htmlsb),$SessionSharing,$htmlwhite))    
                                        If($PubItem.OneInstancePerUser)    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))    
                                        }    
                                        $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$ConCurrentLicenses,$htmlwhite))                                   $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                        $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$LicenseLimitNotify,$htmlwhite))    
                                }    
                                If($PubItem.InheritLicenseDefaultSettings)    
                                {    
                                        $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$DefaultReplicateLicenseSettings.ToString(),$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateLicenseSettings.ToString(),$htmlwhite))                                   $rowdata += @(,("Use for administrative purposes",($Script:htmlsb),$PubItem.AdminOnly.ToString(),$htmlwhite))
                                }    
 
                                WriteHTMLLine 3 0 "Display" <>                                 OutputPubItemFilters $PubItem "HTML"
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$PubItem.InheritDisplayDefaultSettings.ToString(),$htmlwhite)    
     
                                If($PubItem.InheritDisplayDefaultSettings)    
                                {    
                                        $rowdata += @(,("Wait until all RAS Universal Printers are redirected before showing the application",($Script:htmlsb),$DefaultWaitForPrinters,$htmlwhite))    
                                        $rowdata += @(,("Maximum time to wait is",($Script:htmlsb),"$($DefaultWaitForPrintersTimeout) seconds",$htmlwhite))    
                                        $rowdata += @(,("Color Depth",($Script:htmlsb),$DefaultColorDepth,$htmlwhite))    
                                        $rowdata += @(,("Start the application as maximized when using mobile clients",($Script:htmlsb),$DefaultStartMaximized,$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Wait until all RAS Universal Printers are redirected before showing the application",($Script:htmlsb),$PubItem.WaitForPrinters.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Maximum time to wait is",($Script:htmlsb),"$($PubItem.WaitForPrintersTimeout.ToString()) seconds",$htmlwhite))    
                                        $rowdata += @(,("Color Depth",($Script:htmlsb),$ColorDepth,$htmlwhite))    
                                        $rowdata += @(,("Start the application as maximized when using mobile clients",($Script:htmlsb),$PubItem.StartMaximized.ToString(),$htmlwhite))    
                                }    
                                $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateDisplaySettings.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
     
                                WriteHTMLLine 0 0 ""    
 
                ElseIf($PubItem.Type -eq "RDSDesktop") <>                 ElseIf($PubItem.Type -eq "PCApp")
 
                        $DesktopSize = "Unable to determine" +-  
                        If($PubItem.DesktopSize -eq "FullScreen")    
                        {    
                                $DesktopSize = "Full Screen"    
                        }    
                        ElseIf($PubItem.DesktopSize -eq "UseAvailableArea")    
                        {    
                                $DesktopSize = "Use available area"    
                        }    
                        Else    
                        {    
                                $DesktopSize = "$($PubItem.Width.ToString())x$($PubItem.Height.ToString())"    
                        }    
                            
                        Switch ($PubItem.PublishFrom)    
                        {    
                                "All"           {$PublishedFrom = "All Servers in Site"; Break}    
                                "Group"         {$PublishedFrom = "Groups:"; Break}    
                                "Server"        {$PublishedFrom = "Individual Servers:"; Break}    
                                Default         {$PublishedFrom = "Unable to determine Published From: $($PubItem.PublishFrom)"; Break}    
                        }    
                            
                        If($PubItem.AllowMultiMonitor -eq "UseClientSettings")    
                        {    
                                $AllowMultiMonitor = "Use Client Settings"    
                        }    
                        Else    
                        {    
                                $AllowMultiMonitor = $PubItem.AllowMultiMonitor.ToString()    
                        }    
     
 
                                $ScriptInformation.Add(@{Data = "RD Session Host Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Remote PC Application"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Connect to administrative session"; Value = $PubItem.ConnectToConsole.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null
                                $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null                                   $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null
                                    
                                If($PubItem.PublishFrom -eq "Server")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromServer)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")                                   If(![String]::IsNullOrEmpty($PubItem.Parameters))
 
                                        $cnt = -1 <>  
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null                                           $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null    
                                                }    
                                        }    
 
                                Else <>  
                                {                                  
                                        $ScriptInformation.Add(@{Data = "Published from"; Value = "All Servers in Site"; }) > $Null                                   $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null
                                }    
                                    
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
 
                                WriteWordLine 3 0 "Publish from" <>  
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                If($PubItem.PublishFrom -eq "Server")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromServer)    
                                        {    
                                                $cnt++    
                                                    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = ""; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 300;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
     
                                WriteWordLine 3 0 "Desktop"                                   WriteWordLine 3 0 "Remote PC Application"
                                WriteWordLine 4 0 "Desktop"                                   WriteWordLine 4 0 "Application"
 
  <>                                 $ScriptInformation.Add(@{Data = "Run"; Value = $WinType; }) > $Null
                                $ScriptInformation.Add(@{Data = "Connect to administrative session"; Value = $PubItem.ConnectToConsole.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null
 
  +-  
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 300;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                                    
                                WriteWordLine 4 0 "Properties"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Desktop size"; Value = $DesktopSize; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Multi-Monitor"; Value = $AllowMultiMonitor; }) > $Null    
 
                                Line 3 "RD Session Host Desktop`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)" <>                                 Line 3 "Remote PC Application`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
 
  <>                                 Line 3 "Target`t`t`t`t`t`t`t: " $PubItem.Target
                                    Line 3 "Start In`t`t`t`t`t`t: " $PubItem.StartIn
                                Line 3 "Connect to administrative session`t`t`t: " $PubItem.ConnectToConsole.ToString()                                   Line 3 "Start automatically when user logs on`t`t`t: " $PubItem.StartOnLogon.ToString()
                                Line 3 "Desktop Size`t`t`t`t`t`t: " $DesktopSize    
 
                                If($PubItem.PublishFrom -eq "Server") <>  
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromServer)                                   If(![String]::IsNullOrEmpty($PubItem.Parameters))
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 3 "Published from`t`t`t`t`t`t: " ItemName    
                                                }    
                                                Else    
                                                {    
                                                        Line 10 $ItemName    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
 
                                        $cnt = -1 <>  
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 3 "Published from`t`t`t`t`t`t: " ItemName                                           Line 3 "Parameters`t`t`t`t`t`t: " $PubItem.Parameters
                                                }    
                                                Else    
                                                {    
                                                        Line 10 $ItemName    
                                                }    
                                        }    
 
                                Else <>  
                                {                                  
                                        Line 3 "Published from`t`t`t`t`t`t: " "All Servers in Site"                                   Line 3 "Settings for Site $xSiteName"
                                }    
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
                                Line 2 "Publish from" <>  
                                Line 3 $PublishedFrom    
                                If($PubItem.PublishFrom -eq "Server")    
                                {    
                                        ForEach($Item in $PubItem.PublishFromServer)    
                                        {    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                Line 6 $ItemName    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                Line 5 $ItemName    
                                        }    
                                }    
                                Line 0 ""    
                                    
                                Line 2 "Desktop"                                   Line 2 "Remote PC Application"
                                Line 3 "Desktop"                                   Line 3 "Application"
 
                                Line 4 "Connect to administrative session`t`t: " $PubItem.ConnectToConsole.ToString() <>                                 Line 4 "Run`t`t`t`t`t`t: " $WinType
                                    Line 4 "Target`t`t`t`t`t`t: " $PubItem.Target
                                    Line 4 "Start In`t`t`t`t`t: " $PubItem.StartIn
                                    Line 4 "Parameters`t`t`t`t`t: " $PubItem.Parameters
 
                                Line 3 "Properties" +-  
                                Line 4 "Desktop size`t`t`t`t`t: " $DesktopSize    
                                Line 4 "Multi-Monitor`t`t`t`t`t: " $AllowMultiMonitor    
                                Line 0 ""    
     
 
  <>  
                                $columnHeaders = @("RD Session Host Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)                                   $columnHeaders = @("Remote PC Application",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
 
                                $rowdata += @(,("Connect to administrative session",($Script:htmlsb),$PubItem.ConnectToConsole.ToString(),$htmlwhite)) <>                                 $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))
                                $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))                                   $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))
                                    $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
 
                                If($PubItem.PublishFrom -eq "Server") <>  
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromServer)                                   If(![String]::IsNullOrEmpty($PubItem.Parameters))
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
 
                                        $cnt = -1 <>  
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))                                           $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
 
                                Else <>  
                                {                                  
                                        $rowdata += @(,("Published from",($Script:htmlsb),"All Servers in Site",$htmlwhite))                                   $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))
                                }    
                                    
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
                                WriteHTMLLine 3 0 "Publish from" <>  
                                $rowdata = @()    
                                If($PubItem.PublishFrom -eq "Server")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromServer)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        $columnHeaders = @("$PublishedFrom",($Script:htmlsb),"",$htmlwhite)    
                                }    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Desktop"                                   WriteHTMLLine 3 0 "Remote PC Application"
 
  <>                                 $rowdata += @(,("Run",($Script:htmlsb),$WinType,$htmlwhite))
                                $rowdata += @(,("Connect to administrative session",($Script:htmlsb),$PubItem.ConnectToConsole.ToString(),$htmlwhite))                                   $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))
                                    $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))
                                    $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))
 
                                $msg = "Desktop" <>                                 $msg = "Application"
 
                                $rowdata = @() +-  
                                $columnHeaders = @("Desktop size",($Script:htmlsb),$DesktopSize,$htmlwhite)    
                                $rowdata += @(,("Multi-Monitor",($Script:htmlsb),$AllowMultiMonitor,$htmlwhite))    
     
                                $msg = "Properties"    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
 
                ElseIf($PubItem.Type -eq "VDIApp") <>                 ElseIf($PubItem.Type -eq "PCDesktop")
 
                        Switch($PubItem.ConnectTo) <>                         $DesktopSize = "Unable to determine"
                            If($PubItem.DesktopSize -eq "FullScreen")
 
                                "AnyGuest"                              {$ConnectTo = "Any Guest VM"; Break} <>                                 $DesktopSize = "Full Screen"
                                "SpecificRASTemplate"   {$ConnectTo = "Specific Template ($($PubItem.SelectedGuests[0].VDIGuestName))"; Break    
                                                                                }                           }
                                Default                                 {$ConnectTo = "Unable to determine Connect To: $($PubItem.ConnectTo)"; Break}                           ElseIf($PubItem.DesktopSize -eq "UseAvailableArea")
                            {
                                    $DesktopSize = "Use available area"
 
                        <>                         Else
                        $results = Get-RASVDIPool -Id $PubItem.VDIPoolId -EA 0 4>$Null    
                            
                        If($? -and $Null -ne $results)    
 
                                $FromPool = $results.Name <>                                 $DesktopSize = "$($PubItem.Width.ToString())x$($PubItem.Height.ToString())"
 
                        ElseIf($? -and $Null -eq $results) <>                        
                            If($PubItem.AllowMultiMonitor -eq "UseClientSettings")
 
                                $FromPool = "VDI Pool not found for Pool Id $($PubItem.VDIPoolId)" <>                                 $AllowMultiMonitor = "Use Client Settings"
 
                                $FromPool = "Unable to retrieve VDI Pool for Pool Id $($PubItem.VDIPoolId)" <>                                 $AllowMultiMonitor = $PubItem.AllowMultiMonitor.ToString()
 
  -+                                 
 
                                $ScriptInformation.Add(@{Data = "Virtual Desktop Application"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Remote PC Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null    
     
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null    
                                }    
                                    
                                $ScriptInformation.Add(@{Data = "Connect To"; Value = $ConnectTo; }) > $Null    
                                $ScriptInformation.Add(@{Data = "From Pool"; Value = $FromPool; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null
                                    
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null    
                                        }    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null    
                                        }    
                                }    
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 300;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
     
                                WriteWordLine 3 0 "Sites"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null    
                                        }    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 300;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
     
                                WriteWordLine 3 0 "Virtual Desktop Application"    
                                WriteWordLine 4 0 "Application"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Run"; Value = $WinType; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 300;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                                    
                                WriteWordLine 4 0 "Virtual Guest settings"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Connect to"; Value = $ConnectTo; }) > $Null    
                                $ScriptInformation.Add(@{Data = "from Pool"; Value = $FromPool; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Persistent"; Value = $PubItem.Persistent.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 300;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                                    
                                OutputPubItemFilters $PubItem "MSWordPDF"    
                                    
                                OutputPubItemShortcuts $PubItem "MSWordPDF" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Information"    
                                Line 3 "Virtual Desktop Application`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"    
                                Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description    
                                Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod    
                                Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()    
                                Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate    
                                Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()    
                                Line 3 "Target`t`t`t`t`t`t`t: " $PubItem.Target    
                                Line 3 "Start In`t`t`t`t`t`t: " $PubItem.StartIn    
                                Line 3 "Start automatically when user logs on`t`t`t: " $PubItem.StartOnLogon.ToString()    
                                    
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        Line 3 "Parameters`t`t`t`t`t`t: " $PubItem.Parameters    
                                }    
                                    
                                Line 3 "Connect To`t`t`t`t`t`t: " $ConnectTo    
                                Line 3 "From Pool`t`t`t`t`t`t: " $FromPool    
                                Line 3 "Settings for Site $xSiteName"    
     
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                Line 3 "Create shortcut on desktop"    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                Line 3 "Create shortcut on desktop"    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"    
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 "Own Filters"    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        Line 3 " User filtering is enabled"    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                Line 10 "  " $Item.Account    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        Line 3 " IP filtering is enabled"    
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        Line 3 " Client filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        Line 3 " MAC filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        Line 3 " Gateway filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 " Client device operating system filtering is enabled"    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                Line 10 "  Android"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                Line 10 "  ChromeApp"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                Line 10 "  iOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                Line 10 "  Linux"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                Line 10 "  macOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                Line 10 "  RAS Web Portal"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                Line 10 "  Windows"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                Line 10 "  Wyse"    
                                        }    
                                        Line 0 ""    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "Available in Site(s)`t`t`t`t`t: " $SiteName    
                                        }    
                                        Else    
                                        {    
                                                Line 10 $SiteName    
                                        }    
                                }    
                                Line 0 ""    
     
                                Line 2 "Sites"    
                                Line 3 "This published item will be available from the following Sites"    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        Line 10 $SiteName    
                                }    
                                Line 0 ""    
     
                                Line 2 "Virtual Guest settings"    
                                Line 3 "Application"    
                                Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name    
                                Line 4 "Description`t`t`t`t`t: " $PubItem.Description    
                                Line 4 "Run`t`t`t`t`t`t: " $WinType    
                                Line 4 "Target`t`t`t`t`t`t: " $PubItem.Target    
                                Line 4 "Start In`t`t`t`t`t: " $PubItem.StartIn    
                                Line 4 "Parameters`t`t`t`t`t: " $PubItem.Parameters    
                                Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()    
                                Line 0 ""    
                                    
                                Line 3 "Application"    
                                Line 4 "Connect to`t`t`t`t`t: " $ConnectTo    
                                Line 4 "from Pool`t`t`t`t`t: " $FromPool    
                                Line 4 "Persistent`t`t`t`t`t: " $PubItem.Persistent.ToString()    
                                Line 0 ""    
                                    
                                OutputPubItemFilters $PubItem "Text"    
                                    
                                OutputPubItemShortcuts $PubItem "Text" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 3 0 "Information"    
                                $rowdata = @()    
     
                                $columnHeaders = @("Virtual Desktop Application",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))    
                                $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))    
                                $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))    
                                    
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))    
                                }    
                                    
                                $rowdata += @(,("Connect To",($Script:htmlsb),$ConnectTo,$htmlwhite))    
                                $rowdata += @(,("From Pool",($Script:htmlsb),$FromPool,$htmlwhite))    
                                $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))    
                                    
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))    
                                        }    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
                            
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Sites"    
                                $rowdata = @()    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Virtual Guest settings"    
                                $rowdata = @()    
     
                                $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Run",($Script:htmlsb),$WinType,$htmlwhite))    
                                $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))    
                                $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))    
                                $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))    
     
                                $msg = "Application"    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                                    
                                $rowdata = @()    
     
                                $columnHeaders = @("Connect To",($Script:htmlsb),$ConnectTo,$htmlwhite)    
                                $rowdata += @(,("from Pool",($Script:htmlsb),$FromPool,$htmlwhite))    
                                $rowdata += @(,("Persistent",($Script:htmlsb),$PubItem.Persistent.ToString(),$htmlwhite))    
     
                                $msg = "Virtual Guest settings"    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                                    
                                OutputPubItemFilters $PubItem "HTML"    
                                    
                                OutputPubItemShortcuts $PubItem "HTML" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
                        }    
                }    
                ElseIf($PubItem.Type -eq "VDIDesktop")    
                {    
                        Switch($PubItem.ConnectTo)    
                        {    
                                "AnyGuest"                              {$ConnectTo = "Any Guest VM"; Break}    
                                "SpecificRASTemplate"   {$ConnectTo = "Specific Template ($($PubItem.SelectedGuests[0].VDIGuestName))"; Break}    
                                Default                                 {$ConnectTo = "Unable to determine Connect To: $($PubItem.ConnectTo)"; Break}    
                        }    
                            
                        $DesktopSize = "Unable to determine"    
                        If($PubItem.DesktopSize -eq "FullScreen")    
                        {    
                                $DesktopSize = "Full Screen"    
                        }    
                        ElseIf($PubItem.DesktopSize -eq "UseAvailableArea")    
                        {    
                                $DesktopSize = "Use available area"    
                        }    
                        Else    
                        {    
                                $DesktopSize = "$($PubItem.Width.ToString())x$($PubItem.Height.ToString())"    
                        }    
     
                        If($PubItem.AllowMultiMonitor -eq "UseClientSettings")    
                        {    
                                $AllowMultiMonitor = "Use Client Settings"    
                        }    
                        Else    
                        {    
                                $AllowMultiMonitor = $PubItem.AllowMultiMonitor.ToString()    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 3 0 "Information"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Virtual Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Connect to"; Value = $ConnectTo; }) > $Null    
                                    
                                If($PubItem.Persistent)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Published item is persistent"; Value = ""; }) > $Null    
                                }    
                                    
                                $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null    
     
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null    
 
                                WriteWordLine 3 0 "Virtual Desktop" <>                                 WriteWordLine 3 0 "Remote PC Desktop"
                                WriteWordLine 4 0 "Virtual desktop"                                   WriteWordLine 4 0 "Remote PC Desktop"
 
                                $ScriptInformation.Add(@{Data = "Connect to"; Value = $ConnectTo; }) > $Null <>                                 #$ScriptInformation.Add(@{Data = "Select Remote PC"; Value = ""; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Persistent"; Value = $PubItem.Persistent.ToString(); }) > $Null +-  
 
                                 <>  
 
                                Line 3 "Virtual Desktop`t`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)" <>                                 Line 3 "Remote PC Desktop`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
 
                                Line 3 "Settings for Site $xSiteName" +-  
                                Line 3 "Connect to`t`t`t`t`t`t: " $ConnectTo    
                                    
                                If($PubItem.Persistent)    
                                {    
                                        Line 3 "Published item is persistent"    
                                }    
                                    
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
                                Line 2 "Virtual Desktop" <>                                 Line 2 "Remote PC Desktop"
                                Line 3 "Virtual desktop"                                   Line 3 "Remote PC Desktop"
 
                                Line 4 "Connect to`t`t`t`t`t: " $ConnectTo +-  
 
                                Line 4 "Persistent`t`t`t`t`t: " $PubItem.Persistent.ToString() +-  
 
                                $columnHeaders = @("Virtual Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite) <>                                 $columnHeaders = @("Remote PC Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
 
                                $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite)) +-  
                                $rowdata += @(,("Connect to",($Script:htmlsb),$ConnectTo,$htmlwhite))    
                                    
                                If($PubItem.Persistent)    
                                {    
                                        $rowdata += @(,("Published item is persistent",($Script:htmlsb),"",$htmlwhite))    
                                }    
                                    
 
  +-  
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
                         <>  
 
                                WriteHTMLLine 3 0 "Virtual Desktop" <>                                 WriteHTMLLine 3 0 "Remote PC Desktop"
 
  +-  
 
                                $msg = "Desktop" <>                                 $msg = ""
 
                                 <>  
                                    WriteHTMLLine 4 0 "Properties"
 
                                $columnHeaders = @("Connect to",($Script:htmlsb),$ConnectTo,$htmlwhite) <>                                 $columnHeaders = @("Select Remote PC",($Script:htmlsb),"",$htmlwhite)
                                $rowdata += @(,("Desktop size",($Script:htmlsb),$DesktopSize,$htmlwhite))                                   $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))
 
                                $rowdata += @(,("Persistent",($Script:htmlsb),$PubItem.Persistent.ToString(),$htmlwhite)) <>  
                                    
                                $msg = "Properties"                                   $msg = "Remote PC Desktop"
 
                                 <>  
 
                ElseIf($PubItem.Type -eq "WVDApp") <>                 ElseIf($PubItem.Type -eq "RDSApp")
 
                                Default                                         {$LicenseLimitNotify ="Unable to determine If limit is exceeded: $($PubItem.LicenseLimitNotify)"; Break} <>                                 Default {$LicenseLimitNotify ="Unable to determine If limit is exceeded: $($PubItem.LicenseLimitNotify)"; Break}
 
  -+                         
                            Switch($PubItem.EnabledMode)
                            {
                                    "Disabled"              {$PubItemMode = "Disabled"; Break}
                                    "Enabled"               {$PubItemMode = "Enabled"; Break}
                                    "Maintenance"   {$PubItemMode = "In maintenance"; Break}
                                    Default                 {$PubItemMode = "Unable to determine Enabled Mode: $($PubItem.EnabledMode)"; Break}
                            }
 
                                $ScriptInformation.Add(@{Data = "Windows Virtual Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Application"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
 
  -+                                 $ScriptInformation.Add(@{Data = "Status"; Value = $PubItemMode; }) > $Null
 
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite)) <>                                                 $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null
 
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite)) <>                                                 $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null
 
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite)) <>                                                 $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null
 
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite)) <>                                                 $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
 
  -+                                 $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                                    
                                    WriteWordLine 4 0 "Server settings"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
 
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Exclude from session prelaunch"; Value = $PubItem.ExcludePrelaunch.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null
 
  +-  
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 300;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
     
                                $ScriptInformation = New-Object System.Collections.ArrayList    
 
                                $Table.Columns.Item(2).Width = 100; <>                                 $Table.Columns.Item(2).Width = 300;
 
  +-  
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 300;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
     
                                $ScriptInformation = New-Object System.Collections.ArrayList    
 
                                $Table.Columns.Item(2).Width = 100; <>                                 $Table.Columns.Item(2).Width = 300;
 
  +-  
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 300;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                                    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
 
                                $Table.Columns.Item(2).Width = 100; <>                                 $Table.Columns.Item(2).Width = 300;
 
  -+  
 
                                Line 3 "Windows Virtual Desktop`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)" <>                                 Line 3 "Application`t`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
 
  -+                                 Line 3 "Status`t`t`t`t`t`t`t: " $PubItemMode
 
                                                Line 10 $Item <>                                                 Line 10 "  " $Item
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
  -+                                 Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()
                                    Line 0 ""
                                    
                                    Line 3 "Server settings"
 
                                Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString() +-  
                                Line 4 "Exclude from session prelaunch`t`t`t: "; Value = $PubItem.ExcludePrelaunch.ToString()    
 
                                                        Line 8 "Extension:`t" $Item <>                                                         Line 8 "Extension`t: " $Item
 
                                                        Line 10 $Item <>                                                         Line 10 "  " $Item
 
                                Line 3 "Settings are replicated to all Sites: " $PubItem.ReplicateDisplaySettings.ToString() <>                                 Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateDisplaySettings.ToString()
 
                                $columnHeaders = @("Windows Virtual Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite) <>                                 $columnHeaders = @("Application",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
 
  -+                                 $rowdata += @(,("Status",($Script:htmlsb),$PubItemMode,$htmlwhite))
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
  -+                                 $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
     
                                    $msg = "Application"
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                                    
                                    $rowdata = @()
                                    $columnHeaders = @("Server(s)",($Script:htmlsb),"",$htmlwhite)
 
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite)) +-  
                                $rowdata += @(,("Exclude from session prelaunch",($Script:htmlsb),$PubItem.ExcludePrelaunch.ToString(),$htmlwhite))    
 
                                $msg = "Application" <>                                 $msg = "Server settings"
 
                                 <>  
 
  -+                                 $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateFileExtensionSettings.ToString(),$htmlwhite))
 
                                WriteHTMLLine 0 0 "" +-  
 
                                $rowdata = @() +-  
                                $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ReplicateFileExtensionSettings.ToString(),$htmlwhite)    
     
                                $msg = ""    
                                $columnWidths = @("183","100")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
 
  +-  
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                $rowdata = @()    
 
                                        $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$DefaultReplicateLicenseSettings.ToString(),$htmlwhite) <>                                         $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$DefaultReplicateLicenseSettings.ToString(),$htmlwhite))
 
                                        $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ReplicateLicenseSettings.ToString(),$htmlwhite) <>                                         $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateLicenseSettings.ToString(),$htmlwhite))
 
                                $columnWidths = @("183","100") <>                                 $columnWidths = @("200","300")
 
  -+                                 $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateDisplaySettings.ToString(),$htmlwhite))
 
                                WriteHTMLLine 0 0 "" +-  
 
                                $rowdata = @() +-  
                                $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ReplicateDisplaySettings.ToString(),$htmlwhite)    
     
                                $msg = ""    
                                $columnWidths = @("183","100")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
 
                ElseIf($PubItem.Type -eq "WVDDesktop") <>                 ElseIf($PubItem.Type -eq "RDSDesktop")
 
                                $ScriptInformation.Add(@{Data = "Windows Virtual Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "RD Session Host Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
 
  -+                                 $ScriptInformation.Add(@{Data = "Connect to administrative session"; Value = $PubItem.ConnectToConsole.ToString(); }) > $Null
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Exclude from session prelaunch"; Value = $PubItem.ExcludePrelaunch.ToString(); }) > $Null +-  
 
                                Line 3 "Windows Virtual Desktop`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)" <>                                 Line 3 "RD Session Host Desktop`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
 
  -+                                 Line 3 "Connect to administrative session`t`t`t: " $PubItem.ConnectToConsole.ToString()
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
                                Line 4 "Exclude from session prelaunch`t`t`t: " $PubItem.ExcludePrelaunch.ToString() +-  
 
                                $columnHeaders = @("Windows Virtual Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite) <>                                 $columnHeaders = @("RD Session Host Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
 
  -+                                 $rowdata += @(,("Connect to administrative session",($Script:htmlsb),$PubItem.ConnectToConsole.ToString(),$htmlwhite))
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
                                $rowdata += @(,("Exclude from session prelaunch",($Script:htmlsb),$PubItem.ExcludePrelaunch.ToString(),$htmlwhite)) +-  
 
  <>                 ElseIf($PubItem.Type -eq "VDIApp")
                    {
                            Switch($PubItem.ConnectTo)
                            {
                                    "AnyGuest"                              {$ConnectTo = "Any Guest VM"; Break}
                                    "SpecificRASTemplate"   {$ConnectTo = "Specific Template ($($PubItem.SelectedGuests[0].VDIGuestName))"; Break
        }                                                                                   }
                                    Default                                 {$ConnectTo = "Unable to determine Connect To: $($PubItem.ConnectTo)"; Break}
}                           }
                            
                            $results = Get-RASVDIPool -Id $PubItem.VDIPoolId -EA 0 4>$Null
                            
                            If($? -and $Null -ne $results)
                            {
Function OutputPubItemFilters                                   $FromPool = $results.Name
                            }
                            ElseIf($? -and $Null -eq $results)
{                           {
        Param([object] $PubItem, [string] $OutputType)                                   $FromPool = "VDI Pool not found for Pool Id $($PubItem.VDIPoolId)"
                            }
                            Else
                            {
                                    $FromPool = "Unable to retrieve VDI Pool for Pool Id $($PubItem.VDIPoolId)"
                            }
                                  
        If($OutputType -eq "MSWordPDF")                           If($MSWord -or $PDF)
        {                           {
                WriteWordLine 3 0 "Filtering"                                   WriteWordLine 3 0 "Information"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Virtual Desktop Application"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
     
                If(!($PubItem.UserFilterEnabled))                                   If(![String]::IsNullOrEmpty($PubItem.Parameters))
                {                                   {
                        WriteWordLine 0 0 "User filtering not enabled"                                           $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null
                        WriteWordLine 0 0 ""                                   }
                                    
                                    $ScriptInformation.Add(@{Data = "Connect To"; Value = $ConnectTo; }) > $Null
                                    $ScriptInformation.Add(@{Data = "From Pool"; Value = $FromPool; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null
                                    
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                }                                           }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                            }
                                    }
                Else                                   Else
                {                                   {
                        WriteWordLine 0 0 "User filtering is enabled"                                           If($PubItem.CreateShortcutOnDesktop)
                        WriteWordLine 0 0 ""    
                        WriteWordLine 0 0 "Allow the following Users:" -FontSize 9 -Italics $True    
                                            {
                        $ScriptInformation = New-Object System.Collections.ArrayList                                                   $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                        $NameTable = @()                                           }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null
                                                                  
                        ForEach($item in $PubItem.AllowedUsers)                                           ForEach($Item in $PubItem.AllowedUsers)
                        {                                           {
                                $NameTable += @{                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null
                                User = $item.Account;                                           }
                                Type = $item.Type;    
                                SID  = $item.Sid    
 
  <>                                 If($PubItem.IPFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                        }                                                           }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
 
                        If($NameTable.Count -gt 0) <>                                         If($PubItem.AllowedIP6s.Count -gt 0)
                        {                                           {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null
                                            }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
                                $Table = AddWordTable -Hashtable $NameTable `                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns User,Type,SID `                                   -Columns Data,Value `
                                -Headers "User", "Type", "SID" `                                   -List `
 
                                -AutoFit $wdAutoFitContent; <>                                 -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15; <>                                 SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
  -+                                 $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
 
                        } +-  
 
  <>                                 WriteWordLine 3 0 "Sites"
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.UserFilterReplicate.ToString(); }) > $Null                                                   $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
 
                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 100;                                   $Table.Columns.Item(2).Width = 300;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                }    
                    
                If(!($PubItem.ClientFilterEnabled))    
                {    
                        WriteWordLine 0 0 "Client device name filtering not enabled"                                   WriteWordLine 3 0 "Virtual Desktop Application"
                        WriteWordLine 0 0 ""                                   WriteWordLine 4 0 "Application"
                }    
                Else    
                {    
                        WriteWordLine 0 0 "Client device name filtering is enabled"    
                        WriteWordLine 0 0 ""    
                        WriteWordLine 0 0 "Allow the following Clients:" -FontSize 9 -Italics $True    
     
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                        $NameTable = @()    
                            
                        ForEach($item in $PubItem.AllowedClients)                                   $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null
                        {    
                                $NameTable += @{    
                                Client = $item;    
                                }    
                        }    
     
                        If($NameTable.Count -gt 0)    
                        {    
                                $Table = AddWordTable -Hashtable $NameTable `    
                                -Columns Client `    
                                -Headers "Client" `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitContent;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
     
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Run"; Value = $WinType; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ClientFilterReplicate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
 
                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 100;                                   $Table.Columns.Item(2).Width = 300;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                }                                   
                If(!($PubItem.OSFilterEnabled))    
                {    
                        WriteWordLine 0 0 "Client device operating system filtering not enabled"    
                        WriteWordLine 0 0 ""    
                }    
                Else    
                {    
                        WriteWordLine 0 0 "Client device operating system filtering is enabled"                                   WriteWordLine 4 0 "Virtual Guest settings"
                        WriteWordLine 0 0 ""    
                        WriteWordLine 0 0 "Allow access to clients running on the following operating system:" -FontSize 9 -Italics $True    
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                        If($PubItem.AllowedOSes.Android)    
                        {    
                                $ScriptInformation.Add(@{Data = "Android"; Value = "Enabled"; }) > $Null                                   $ScriptInformation.Add(@{Data = "Connect to"; Value = $ConnectTo; }) > $Null
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "Android"; Value = "Disabled"; }) > $Null    
                        }    
                            
                        If($PubItem.AllowedOSes.Chrome)    
                        {    
                                $ScriptInformation.Add(@{Data = "ChromeApp"; Value = "Enabled"; }) > $Null                                   $ScriptInformation.Add(@{Data = "from Pool"; Value = $FromPool; }) > $Null
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "ChromeApp"; Value = "Disabled"; }) > $Null    
                        }    
                            
                        If($PubItem.AllowedOSes.HTML5)    
                        {    
                                $ScriptInformation.Add(@{Data = "HTML5"; Value = "Enabled"; }) > $Null    
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "HTML5"; Value = "Disabled"; }) > $Null    
                        }    
                            
                        If($PubItem.AllowedOSes.iOS)    
                        {    
                                $ScriptInformation.Add(@{Data = "iOS"; Value = "Enabled"; }) > $Null    
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "iOS"; Value = "Disabled"; }) > $Null    
                        }    
                            
                        If($PubItem.AllowedOSes.Linux)    
                        {    
                                $ScriptInformation.Add(@{Data = "Linux"; Value = "Enabled"; }) > $Null    
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "Linux"; Value = "Disabled"; }) > $Null    
                        }    
                            
                        If($PubItem.AllowedOSes.Mac)    
                        {    
                                $ScriptInformation.Add(@{Data = "macOS"; Value = "Enabled"; }) > $Null    
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "macOS"; Value = "Disabled"; }) > $Null    
                        }    
                            
                        If($PubItem.AllowedOSes.WebPortal)    
                        {    
                                $ScriptInformation.Add(@{Data = "RAS Web Portal"; Value = "Enabled"; }) > $Null    
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "RAS Web Portal"; Value = "Disabled"; }) > $Null    
                        }    
                            
                        If($PubItem.AllowedOSes.Windows)    
                        {    
                                $ScriptInformation.Add(@{Data = "Windows"; Value = "Enabled"; }) > $Null    
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "Windows"; Value = "Disabled"; }) > $Null    
                        }    
                            
                        If($PubItem.AllowedOSes.Wyse)    
                        {    
                                $ScriptInformation.Add(@{Data = "Wyse"; Value = "Enabled"; }) > $Null    
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "Wyse"; Value = "Disabled"; }) > $Null    
                        }    
                            
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitContent;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
     
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.OSFilterReplicate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Persistent"; Value = $PubItem.Persistent.ToString(); }) > $Null
 
                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 100;                                   $Table.Columns.Item(2).Width = 300;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                    
                                    OutputPubItemFilters $PubItem "MSWordPDF"
                                    
                                    OutputPubItemShortcuts $PubItem "MSWordPDF" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
                }                           }
                            If($Text)
                            {
                                    Line 2 "Information"
                                    Line 3 "Virtual Desktop Application`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
                                    Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description
                                    Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod
                                    Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate
                                    Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()
                                    Line 3 "Target`t`t`t`t`t`t`t: " $PubItem.Target
                                    Line 3 "Start In`t`t`t`t`t`t: " $PubItem.StartIn
                                    Line 3 "Start automatically when user logs on`t`t`t: " $PubItem.StartOnLogon.ToString()
                                                  
                If(!($PubItem.IPFilterEnabled))                                   If(![String]::IsNullOrEmpty($PubItem.Parameters))
                {                                   {
                                            Line 3 "Parameters`t`t`t`t`t`t: " $PubItem.Parameters
                                    }
                                    
                                    Line 3 "Connect To`t`t`t`t`t`t: " $ConnectTo
                                    Line 3 "From Pool`t`t`t`t`t`t: " $FromPool
                        WriteWordLine 0 0 "IP Address filtering not enabled"                                   Line 3 "Settings for Site $xSiteName"
                        WriteWordLine 0 0 ""    
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    Line 3 "Create shortcut on desktop"
                }                                           }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    Line 3 "Create shortcut in Auto Start Folder"
                                            }
                                    }
                Else                                   Else
                {                                   {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    Line 3 "Create shortcut on desktop"
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    Line 3 "Create shortcut in Auto Start Folder"
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            Line 3 "Own Filters"
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                        WriteWordLine 0 0 "IP Address filtering is enabled"                                           Line 3 " User filtering is enabled"
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    Line 10 "  " $Item.Account
                                            }
                        WriteWordLine 0 0 ""                                           Line 0 ""
                        WriteWordLine 0 0 "Allow the following IPs:" -FontSize 9 -Italics $True                                   }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            Line 3 " IP filtering is enabled"
                        If($PubItem.AllowedIP4s.Count -gt 0)                                           If($PubItem.AllowedIP4s.Count -gt 0)
                        {                                           {
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $NameTable = @()    
                                    
                                ForEach($item in $PubItem.AllowedIP4s)                                                   ForEach($item in $PubItem.AllowedIP4s)
                                {                                                   {
                                        If($item.From -eq $item.To)                                                           If($item.From -eq $item.To)
                                        {                                                           {
                                                $NameTable += @{    
                                                IPv4From = $item.From;                                                                   Line 10 "  " $item.From
                                                IPv4To   = ""                                                           }
                                                            Else
                                                            {
                                                                    Line 10 "  $($item.From) - $($item.To)"
                                                            }
 
  <>  
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    Line 10 "  " $item.From
                                                            }
                                        Else                                                           Else
                                        {                                                           {
                                                $NameTable += @{                                                                   Line 10 "  $($item.From) - $($item.To)"
                                                IPv4From = $item.From;                                                           }
                                                IPv4To   = $item.To    
 
  -+                                         Line 0 ""
 
  <>                                 If($PubItem.ClientFilterEnabled)
                                    {
                                            Line 3 " Client filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                                If($NameTable.Count -gt 0)                                   If($PubItem.MACFilterEnabled)
 
                                        $Table = AddWordTable -Hashtable $NameTable ` <>                                         Line 3 " MAC filtering is enabled"
                                        -Columns IPv4From,IPv4To `                                          
                                        -Headers "IPv4 Address From", "IPv4 Address To" `                                           ForEach($item in $PubItem.AllowedMACs)
                                        -Format $wdTableGrid `                                           {
                                        -AutoFit $wdAutoFitContent;                                                   Line 10 "  " $Item
                                            }
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite                                           Line 0 ""
                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           Line 3 " Gateway filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                        FindWordDocumentEnd                                                   Line 10 "  " $Item
                                        $Table = $Null                                           }
                                            Line 0 ""
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            Line 3 " Client device operating system filtering is enabled"
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                        WriteWordLine 0 0 ""                                                   Line 10 "  Android"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    Line 10 "  Chrome OS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    Line 10 "  iOS/iPadOS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    Line 10 "  Linux"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    Line 10 "  macOS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    Line 10 "  RAS Web Portal"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    Line 10 "  Windows"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    Line 10 "  Wyse"
                                            }
                                            Line 0 ""
 
  -+  
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    Line 3 "Available in Site(s)`t`t`t`t`t: " $SiteName
                                            }
                                            Else
                                            {
                                                    Line 10 $SiteName
                                            }
                                    }
                                    Line 0 ""
     
                                    Line 2 "Sites"
                                    Line 3 "This published item will be available from the following Sites"
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            Line 10 $SiteName
                                    }
                                    Line 0 ""
     
                                    Line 2 "Virtual Guest settings"
                                    Line 3 "Application"
                                    Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name
                                    Line 4 "Description`t`t`t`t`t: " $PubItem.Description
                                    Line 4 "Run`t`t`t`t`t`t: " $WinType
                                    Line 4 "Target`t`t`t`t`t`t: " $PubItem.Target
                                    Line 4 "Start In`t`t`t`t`t: " $PubItem.StartIn
                                    Line 4 "Parameters`t`t`t`t`t: " $PubItem.Parameters
                                    Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()
                                    Line 0 ""
                                    
                                    Line 3 "Application"
                                    Line 4 "Connect to`t`t`t`t`t: " $ConnectTo
                                    Line 4 "from Pool`t`t`t`t`t: " $FromPool
                                    Line 4 "Persistent`t`t`t`t`t: " $PubItem.Persistent.ToString()
                                    Line 0 ""
                                    
                                    OutputPubItemFilters $PubItem "Text"
                                    
                                    OutputPubItemShortcuts $PubItem "Text" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
 
  <>                         If($HTML)
                            {
                                    WriteHTMLLine 3 0 "Information"
                                    $rowdata = @()
     
                                    $columnHeaders = @("Virtual Desktop Application",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))
                                    $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))
                                    $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
                                                          
                                    If(![String]::IsNullOrEmpty($PubItem.Parameters))
                                    {
                                            $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))
                                    }
                                    
                                    $rowdata += @(,("Connect To",($Script:htmlsb),$ConnectTo,$htmlwhite))
                                    $rowdata += @(,("From Pool",($Script:htmlsb),$FromPool,$htmlwhite))
                                    $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))
                                    
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                                            }
                                                    }
                                            }
     
                        If($PubItem.AllowedIP6s.Count -gt 0)                                           If($PubItem.AllowedIP6s.Count -gt 0)
                        {                                           {
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $NameTable = @()    
                                    
                                ForEach($item in $PubItem.AllowedIP6s)                                                   ForEach($item in $PubItem.AllowedIP6s)
                                {                                                   {
                                        If($item.From -eq $item.To)                                                           If($item.From -eq $item.To)
                                        {                                                           {
                                                $NameTable += @{                                                                   $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                                IPv6From = $item.From;                                                           }
                                                IPv6To   = ""                                                           Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                                            }
 
  -+                                 }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))
                                            }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))
                                            }
 
                                                $NameTable += @{ <>                                                 $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                                                IPv6From = $item.From;    
                                                IPv6To   = $item.To    
                                                }                                           }
                                        }                                   }
                            
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Sites"
                                    $rowdata = @()
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)
                                }                                           }
                                            Else
                                If( $NameTable.Count -gt 0)    
                                {                                           {
                                        $Table = AddWordTable -Hashtable $NameTable `                                                   $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                                        -Columns IPv6From,IPv6To `                                           }
                                        -Headers "IPv6 Address From", "IPv6 Address To" `                                   }
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Virtual Guest settings"
                                        -Format $wdTableGrid `                                   $rowdata = @()
                                        -AutoFit $wdAutoFitContent;    
                                    $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Run",($Script:htmlsb),$WinType,$htmlwhite))
                                    $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))
                                    $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))
                                    $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))
                                    $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
 
  <>                                 $msg = "Application"
                                    $columnWidths = @("200","300")
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   WriteHTMLLine 0 0 ""
                                    
                                    $rowdata = @()
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $columnHeaders = @("Connect To",($Script:htmlsb),$ConnectTo,$htmlwhite)
                                    $rowdata += @(,("from Pool",($Script:htmlsb),$FromPool,$htmlwhite))
                                    $rowdata += @(,("Persistent",($Script:htmlsb),$PubItem.Persistent.ToString(),$htmlwhite))
 
                                        FindWordDocumentEnd <>                                 $msg = "Virtual Guest settings"
                                        $Table = $Null                                   $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        WriteWordLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                    
                                    OutputPubItemFilters $PubItem "HTML"
                                    
                                    OutputPubItemShortcuts $PubItem "HTML" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
                                }                           }
                    }
                    ElseIf($PubItem.Type -eq "VDIDesktop")
                    {
                            Switch($PubItem.ConnectTo)
                            {
                                    "AnyGuest"                              {$ConnectTo = "Any Guest VM"; Break}
                                    "SpecificRASTemplate"   {$ConnectTo = "Specific Template ($($PubItem.SelectedGuests[0].VDIGuestName))"; Break}
                                    Default                                 {$ConnectTo = "Unable to determine Connect To: $($PubItem.ConnectTo)"; Break}
 
  -+                         
                            $DesktopSize = "Unable to determine"
                            If($PubItem.DesktopSize -eq "FullScreen")
                            {
                                    $DesktopSize = "Full Screen"
                            }
                            ElseIf($PubItem.DesktopSize -eq "UseAvailableArea")
                            {
                                    $DesktopSize = "Use available area"
                            }
                            Else
                            {
                                    $DesktopSize = "$($PubItem.Width.ToString())x$($PubItem.Height.ToString())"
                            }
 
  <>                         If($PubItem.AllowMultiMonitor -eq "UseClientSettings")
                            {
                                    $AllowMultiMonitor = "Use Client Settings"
                            }
                            Else
                            {
                                    $AllowMultiMonitor = $PubItem.AllowMultiMonitor.ToString()
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Information"
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Virtual Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.IPFilterReplicate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Connect to"; Value = $ConnectTo; }) > $Null
                                    
                                    If($PubItem.Persistent)
                                    {
                                            $ScriptInformation.Add(@{Data = "Published item is persistent"; Value = ""; }) > $Null
                                    }
                                    
                                    $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null
     
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null
                                            }
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null
                                            }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
 
                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 100;                                   $Table.Columns.Item(2).Width = 300;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                }    
                                    WriteWordLine 3 0 "Sites"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                    
                                    $cnt =-1
                If(!($PubItem.MACFilterEnabled))                                   ForEach($Site in $PubItem.PublishToSite)
                {                                   {
                        WriteWordLine 0 0 "MAC filtering not enabled"                                           $cnt++
                        WriteWordLine 0 0 ""                                           $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null
                }                                           }
                Else                                           Else
                {                                           {
                        WriteWordLine 0 0 "MAC filtering is enabled"                                                   $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                        WriteWordLine 0 0 ""    
                        WriteWordLine 0 0 "Allow the following MACs:" -FontSize 9 -Italics $True    
     
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $NameTable = @()    
                            
                        ForEach($item in $PubItem.AllowedMACs)    
                        {    
                                $NameTable += @{    
                                MAC = $item;    
                                }                                           }
                        }                                   }
     
                        If($NameTable.Count -gt 0)    
                        {    
                                $Table = AddWordTable -Hashtable $NameTable `    
                                -Columns MAC `    
                                -Headers "MAC" `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitContent;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
     
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.MACFilterReplicate.ToString(); }) > $Null    
 
                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 100;                                   $Table.Columns.Item(2).Width = 300;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) +-  
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
                }    
                    
                If(!($PubItem.GWFilterEnabled))    
                {    
                        WriteWordLine 0 0 "Gateway filtering not enabled"    
                        WriteWordLine 0 0 ""    
                }    
                Else    
                {    
                        WriteWordLine 0 0 "Gateway filtering is enabled"    
                        WriteWordLine 0 0 ""    
                        WriteWordLine 0 0 "Allow connections from the following Gateways:" -FontSize 9 -Italics $True    
     
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $NameTable = @()    
                            
                        ForEach($item in $PubItem.AllowedGWs)    
                        {    
                                $NameTable += @{    
                                GW = $item;    
                                }    
                        }    
     
                        If($NameTable.Count -gt 0)    
                        {    
                                $Table = AddWordTable -Hashtable $NameTable `    
                                -Columns GW `    
                                -Headers "Gateways" `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitContent;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
 
  +-  
 
                        } +-  
                }    
        }    
        If($OutputType -eq "Text")    
        {    
                Line 2 "Filtering"    
                If(!($PubItem.UserFilterEnabled))    
                {    
                        Line 3 "User filtering not enabled"    
                        Line 0 ""    
                }    
                Else    
                {    
                        Line 3 "User filtering is enabled"    
                        Line 3 "Allow the following Users:"    
                        Line 0 ""    
                            
                        $maxLength = ($PubItem.AllowedUsers.Account | Measure-Object -Property length -Maximum).Maximum    
                        $NegativeMaxLength = $maxLength * -1    
                        Line 3 "User" -nonewline    
                        Line 0 (" " * ($maxLength - 3)) -nonewline    
                        LIne 0 "Type  SID"    
                        Line 3 ("=" * ($maxLength + 1 + 6 + 45)) # $maxLength, space, "Type" plus 2 spaces, length of SID    
                        ForEach($item in $PubItem.AllowedUsers)    
                        {    
                                Line 3 ("{0,$NegativeMaxLength} {1,-5} {2,-45}" -f $item.Account,$item.Type,$item.Sid)    
                        }    
                        Line 0 ""    
 
                        Line 3 "Settings are replicated to all Sites: " $PubItem.UserFilterReplicate.ToString() <>  
                        Line 0 ""    
                }    
                    
                If(!($PubItem.ClientFilterEnabled))    
                {    
                        Line 3 "Client device name filtering not enabled"    
                        Line 0 ""    
                }    
                Else    
                {    
                        Line 3 "Client device name filtering is enabled"    
                        Line 3 "Allow the following Clients:"    
                        Line 0 ""    
                        Line 3 "Client         "    
                        Line 3 "==============="    
                        ForEach($item in $PubItem.AllowedClients)    
                        {    
                                Line 3 ("{0,-15}" -f $item)    
                        }    
                        Line 0 ""    
     
                        Line 3 "Settings are replicated to all Sites: " $PubItem.ClientFilterReplicate.ToString()    
                        Line 0 ""    
                }    
                    
                If(!($PubItem.OSFilterEnabled))    
                {    
                        Line 3 "Client device operating system filtering not enabled"    
                        Line 0 ""    
                }    
                Else    
                {    
                        Line 3 "Client device operating system filtering is enabled"    
                        Line 3 "Allow access to clients running on the following operating system:"    
                        Line 0 ""    
                        Line 3 "Operating system"    
                        Line 3 "================"    
                        If($PubItem.AllowedOSes.Android)    
                        {    
                                Line 3 "Android`t`t: " "Enabled"    
                        }    
                        Else    
                        {    
                                Line 3 "Android`t`t: " "Disabled"    
                        }    
                            
                        If($PubItem.AllowedOSes.Chrome)    
                        {    
                                Line 3 "ChromeApp`t: " "Enabled"    
                        }    
                        Else    
                        {    
                                Line 3 "ChromeApp`t: " "Disabled"    
                        }    
                            
                        If($PubItem.AllowedOSes.HTML5)    
                        {    
                                Line 3 "HTML5`t`t: " "Enabled"    
                        }    
                        Else    
                        {    
                                Line 3 "HTML5`t`t: " "Disabled"    
                        }    
                            
                        If($PubItem.AllowedOSes.iOS)    
                        {    
                                Line 3 "iOS`t`t: " "Enabled"    
                        }    
                        Else    
                        {    
                                Line 3 "iOS`t`t: " "Disabled"    
                        }    
                            
                        If($PubItem.AllowedOSes.Linux)    
                        {    
                                Line 3 "Linux`t`t: " "Enabled"    
                        }    
                        Else    
                        {    
                                Line 3 "Linux`t`t: " "Disabled"    
                        }    
                            
                        If($PubItem.AllowedOSes.Mac)    
                        {    
                                Line 3 "macOS`t`t: " "Enabled"    
                        }    
                        Else    
                        {    
                                Line 3 "macOS`t`t: " "Disabled"    
                        }    
                            
                        If($PubItem.AllowedOSes.WebPortal)    
                        {    
                                Line 3 "RAS Web Portal`t: " "Enabled"    
                        }    
                        Else    
                        {    
                                Line 3 "RAS Web Portal`t: " "Disabled"    
                        }    
                            
                        If($PubItem.AllowedOSes.Windows)    
                        {    
                                Line 3 "Windows`t`t: " "Enabled"    
                        }    
                        Else    
                        {    
                                Line 3 "Windows`t`t: " "Disabled"    
                        }    
                            
                        If($PubItem.AllowedOSes.Wyse)    
                        {    
                                Line 3 "Wyse`t`t: " "Enabled"    
                        }    
                        Else    
                        {    
                                Line 3 "Wyse`t`t: " "Disabled"    
                        }    
                        Line 0 ""    
     
                        Line 3 "Settings are replicated to all Sites: " $PubItem.OSFilterReplicate.ToString()    
                        Line 0 ""    
                }    
                    
                If(!($PubItem.IPFilterEnabled))    
                {    
                        Line 3 "IP Address filtering not enabled"    
                        Line 0 ""    
                }    
                Else    
                {    
                        Line 3 "IP Address filtering is enabled"    
                        Line 3 "Allow the following IPs:"    
                        Line 0 ""    
                            
                        If($PubItem.AllowedIP4s.Count -gt 0)    
                        {    
                                Line 3 "IPv4 Address From  IPv4 Address To"    
                                Line 3 "=================================="    
                                #       255.255.255.255    255.255.255.255    
                                #       123456789012345SSSS123456789012345    
                                ForEach($item in $PubItem.AllowedIP4s)    
                                {    
                                        If($item.From -eq $item.To)    
                                        {    
                                                Line 3 ("{0,-15}" -f $item.From)    
                                        }    
                                        Else    
                                        {    
                                                Line 3 ("{0,-15}    {1,-15}" -f $item.From, $Item.To)    
                                        }    
                                }    
                                    
                                Line 0 ""    
                        }    
                            
                        If($PubItem.AllowedIP6s.Count -gt 0)    
                        {    
                                $MaxFrom    = ($PubItem.AllowedIP6s.From | Measure-Object -Property length -maximum).Maximum    
                                $MaxTo      = ($PubItem.AllowedIP6s.To | Measure-Object -Property length -maximum).Maximum    
                                $NegMaxFrom = $MaxFrom * -1    
                                $NegMaxTo   = $MaxTo * -1    
                                    
                                $SpacesFrom = $MaxFrom - 17    
                                $SpacesTo   = $MaxTo - 15    
                                If($SpacesFrom -le 0)    
                                {    
                                        $SpacesFrom = 17    
                                }    
                                If($SpacesTo -le 0)    
                                {    
                                        $SpacesTo = 15    
                                }    
                                Line 3 "IPv6 Address From  " -nonewline    
                                Line 0 (" " * $SpacesFrom) -nonewline    
                                Line 0 "IPv6 Address To" -nonewline    
                                Line 0 (" " * $SpacesTo)    
                                Line 3 ("=" * (($MaxFrom + $MaxTo) + 2))    
     
                                ForEach($item in $PubItem.AllowedIP6s)    
                                {    
                                        If($item.From -eq $item.To)    
                                        {    
                                                Line 3 ("{0,$NegMaxFrom}" -f $item.From)    
                                        }    
                                        Else    
                                        {    
                                                Line 3 ("{0,$NegMaxFrom}  {1,$NegMaxTo}" -f $item.From, $Item.To)    
                                        }    
                                }    
                                    
                                Line 0 ""    
                        }    
     
                        Line 3 "Settings are replicated to all Sites: " $PubItem.IPFilterReplicate.ToString()    
                        Line 0 ""    
                }    
                    
                If(!($PubItem.MACFilterEnabled))    
                {    
                        Line 3 "MAC filtering not enabled"    
                        Line 0 ""    
                }    
                Else    
                {    
                        Line 3 "MAC filtering is enabled"    
                        Line 3 "Allow the following MACs:"    
                        Line 0 ""    
                        Line 3 "MAC         "    
                        Line 3 "============"    
                        #       123456789012    
                        ForEach($item in $PubItem.AllowedMACs)    
                        {    
                                Line 3 ("{0,-12}" -f $item)    
                        }    
                        Line 0 ""    
     
                        Line 3 "Settings are replicated to all Sites: " $PubItem.MACFilterReplicate.ToString()    
                        Line 0 ""    
                }    
                    
                If(!($PubItem.GWFilterEnabled))    
                {    
                        Line 3 "Gateway filtering not enabled"    
                        Line 0 ""    
                }    
                Else    
                {    
                        Line 3 "Gateway filtering is enabled"    
                        Line 3 "Allow connections from the following Gateways:"    
                        Line 0 ""    
                        Line 3 "Gateways       "    
                        Line 3 "==============="    
                        #       123456789012345    
                        ForEach($item in $PubItem.AllowedGWs)    
                        {    
                                Line 3 ("{0,-15}" -f $item)    
                        }    
                        Line 0 ""    
                }    
        }    
        If($OutputType -eq "HTML")    
        {    
                WriteHTMLLine 3 0 "Filtering"    
                If(!($PubItem.UserFilterEnabled))    
                {    
                        WriteHTMLLine 0 0 "User filtering not enabled"    
                        WriteHTMLLine 0 0 ""    
                }    
                Else    
                {    
                        WriteHTMLLine 0 0 "User filtering is enabled"    
     
                        $rowdata = @()    
                            
                        ForEach($item in $PubItem.AllowedUsers)    
                        {    
                                $rowdata += @(,(    
                                $item.Account,$htmlwhite,    
                                $item.Type,$htmlwhite,    
                                $item.Sid,$htmlwhite))    
                        }    
     
                        $columnHeaders = @(    
                        "User",($Script:htmlsb),    
                        "Type",($Script:htmlsb),    
                        "SID",($Script:htmlsb))    
     
                        $msg = "Allow the following Users:"    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders    
                        WriteHTMLLine 0 0 ""    
     
                        $rowdata = @()    
                        $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.UserFilterReplicate.ToString(),$htmlwhite)    
     
                        $msg = ""    
                        $columnWidths = @("183","100")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }    
                    
                If(!($PubItem.ClientFilterEnabled))    
                {    
                        WriteHTMLLine 0 0 "Client device name filtering not enabled"    
                        WriteHTMLLine 0 0 ""    
                }    
                Else    
                {    
                        WriteHTMLLine 0 0 "Client device name filtering is enabled"    
     
                        $rowdata = @()    
                            
                        ForEach($item in $PubItem.AllowedClients)    
                        {    
                                $rowdata += @(,(    
                                $item,$htmlwhite))    
                        }    
     
                        $columnHeaders = @(    
                        "Client",($Script:htmlsb))    
     
                        $msg = "Allow the following Clients:"    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders     
                        WriteHTMLLine 0 0 ""    
     
                        $rowdata = @()    
                        $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ClientFilterReplicate.ToString(),$htmlwhite)    
     
                        $msg = ""    
                        $columnWidths = @("183","100")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }    
                If(!($PubItem.OSFilterEnabled))    
                {    
                        WriteHTMLLine 0 0 "Client device operating system filtering not enabled"    
                        WriteHTMLLine 0 0 ""    
                }    
                Else    
                {    
                        WriteHTMLLine 0 0 "Client device operating system filtering is enabled"    
                        $rowdata = @()    
     
                        If($PubItem.AllowedOSes.Android)    
                        {    
                                $columnHeaders = @("Android",($Script:htmlsb),"Enabled",$htmlwhite)    
                        }    
                        Else    
                        {    
                                $columnHeaders = @("Android",($Script:htmlsb),"Disabled",$htmlwhite)    
                        }    
                            
                        If($PubItem.AllowedOSes.Chrome)    
                        {    
                                $rowdata += @(,("ChromeApp",($Script:htmlsb),"Enabled",$htmlwhite))    
                        }    
                        Else    
                        {    
                                $rowdata += @(,("ChromeApp",($Script:htmlsb),"Disabled",$htmlwhite))    
                        }    
                            
                        If($PubItem.AllowedOSes.HTML5)    
                        {    
                                $rowdata += @(,("HTML5",($Script:htmlsb),"Enabled",$htmlwhite))    
                        }    
                        Else    
                        {    
                                $rowdata += @(,("HTML5",($Script:htmlsb),"Disabled",$htmlwhite))    
                        }    
                            
                        If($PubItem.AllowedOSes.iOS)    
                        {    
                                $rowdata += @(,("iOS",($Script:htmlsb),"Enabled",$htmlwhite))    
                        }    
                        Else    
                        {    
                                $rowdata += @(,("iOS",($Script:htmlsb),"Disabled",$htmlwhite))    
                        }    
                            
                        If($PubItem.AllowedOSes.Linux)    
                        {    
                                $rowdata += @(,("Linux",($Script:htmlsb),"Enabled",$htmlwhite))    
                        }    
                        Else    
                        {    
                                $rowdata += @(,("Linux",($Script:htmlsb),"Disabled",$htmlwhite))    
                        }    
                            
                        If($PubItem.AllowedOSes.Mac)    
                        {    
                                $rowdata += @(,("macOS",($Script:htmlsb),"Enabled",$htmlwhite))    
                        }    
                        Else    
                        {    
                                $rowdata += @(,("macOS",($Script:htmlsb),"Disabled",$htmlwhite))    
                        }    
                            
                        If($PubItem.AllowedOSes.WebPortal)    
                        {    
                                $rowdata += @(,("RAS Web Portal",($Script:htmlsb),"Enabled",$htmlwhite))    
                        }    
                        Else    
                        {    
                                $rowdata += @(,("RAS Web Portal",($Script:htmlsb),"Disabled",$htmlwhite))    
                        }    
                            
                        If($PubItem.AllowedOSes.Windows)    
                        {    
                                $rowdata += @(,("Windows",($Script:htmlsb),"Enabled",$htmlwhite))    
                        }    
                        Else    
                        {    
                                $rowdata += @(,("Windows",($Script:htmlsb),"Disabled",$htmlwhite))    
                        }    
                            
                        If($PubItem.AllowedOSes.Wyse)    
                        {    
                                $rowdata += @(,("Wyse",($Script:htmlsb),"Enabled",$htmlwhite))    
                        }    
                        Else    
                        {    
                                $rowdata += @(,("Wyse",($Script:htmlsb),"Disabled",$htmlwhite))    
                        }    
                            
                        $msg = "Allow access to clients running on the following operating system:"    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders     
                        WriteHTMLLine 0 0 ""    
     
                        $rowdata = @()    
                        $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.OSFilterReplicate.ToString(),$htmlwhite)    
     
                        $msg = ""    
                        $columnWidths = @("183","100")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }    
                    
                If(!($PubItem.IPFilterEnabled))    
                {    
                        WriteHTMLLine 0 0 "IP Address filtering not enabled"    
                        WriteHTMLLine 0 0 ""    
                }    
                Else    
                {    
                        WriteHTMLLine 0 0 "IP Address filtering is enabled"    
     
                        If($PubItem.AllowedIP4s.Count -gt 0)    
                        {    
                                $rowdata = @()    
                                    
                                ForEach($item in $PubItem.AllowedIP4s)    
                                {    
                                        If($item.From -eq $item.To)    
                                        {    
                                                $rowdata += @(,(    
                                                $item.From,$htmlwhite,    
                                                "",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,(    
                                                $item.From,$htmlwhite,    
                                                $item.To,$htmlwhite))    
                                        }    
                                }    
     
                                $columnHeaders = @(    
                                "IPv4 Address From",($Script:htmlsb),    
                                "IPv4 Address To",($Script:htmlsb))    
     
                                $msg = "Allow the following IPs:"    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders    
                                If($PubItem.AllowedIP6s.Count -gt 0)    
                                {    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
     
                        If($PubItem.AllowedIP6s.Count -gt 0)    
                        {    
                                $rowdata = @()    
                                    
                                ForEach($item in $PubItem.AllowedIP6s)    
                                {    
                                        If($item.From -eq $item.To)    
                                        {    
                                                $rowdata += @(,(    
                                                $item.From,$htmlwhite,    
                                                "",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,(    
                                                $item.From,$htmlwhite,    
                                                $item.To,$htmlwhite))    
                                        }    
                                }    
     
                                $columnHeaders = @(    
                                "IPv6 Address From",($Script:htmlsb),    
                                "IPv6 Address To",($Script:htmlsb))    
     
                                If($PubItem.AllowedIP4s.Count -gt 0)    
                                {    
                                        $msg = ""    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders    
                                }    
                                Else    
                                {    
                                        $msg = "Allow the following IPs:"    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders    
                                }    
                        }    
                        WriteHTMLLine 0 0 ""    
     
                        $rowdata = @()    
                        $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.IPFilterReplicate.ToString(),$htmlwhite)    
     
                        $msg = ""    
                        $columnWidths = @("183","100")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }    
                    
                If(!($PubItem.MACFilterEnabled))    
                {    
                        WriteHTMLLine 0 0 "MAC filtering not enabled"    
                        WriteHTMLLine 0 0 ""    
                }    
                Else    
                {    
                        WriteHTMLLine 0 0 "MAC filtering is enabled"    
                        WriteHTMLLine 0 0 "Allow the following MACs:"    
     
                        $rowdata = @()    
                            
                        ForEach($item in $PubItem.AllowedMACs)    
                        {    
                                $rowdata += @(,(    
                                $item,$htmlwhite))    
                        }    
     
                        $columnHeaders = @(    
                        "MAC",($Script:htmlsb))    
     
                        $msg = ""    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders     
                        WriteHTMLLine 0 0 ""    
     
                        $rowdata = @()    
                        $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.MACFilterReplicate.ToString(),$htmlwhite)    
     
                        $msg = ""    
                        $columnWidths = @("183","100")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }    
                    
                If(!($PubItem.GWFilterEnabled))    
                {    
                        WriteHTMLLine 0 0 "Gateway filtering not enabled"    
                        WriteHTMLLine 0 0 ""    
                }    
                Else    
                {    
                        WriteHTMLLine 0 0 "Gateway filtering is enabled"    
                        WriteHTMLLine 0 0 "Allow connections from the following Gateways:"    
     
                        $rowdata = @()    
                            
                        ForEach($item in $PubItem.AllowedGWs)    
                        {    
                                $rowdata += @(,(    
                                $item,$htmlwhite))    
                        }    
     
                        $columnHeaders = @(    
                        "Gateways",($Script:htmlsb))    
     
                        $msg = ""    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders     
                        WriteHTMLLine 0 0 ""    
                            
                        #there is no replication setting for Gateway filters    
                }    
        }    
}    
     
Function OutputPubItemShortCuts    
{    
        Param([object] $PubItem,     
        [string] $OutputType,    
        [string] $DefaultCreateShortcutOnDesktop,    
        [string] $DefaultCreateShortcutInStartFolder,    
        [string] $DefaultStartPath,    
        [string] $DefaultCreateShortcutInStartUpFolder,    
        [string] $DefaultReplicateShortcutSettings    
        )    
            
        If($OutputType -eq "MSWordPDF")    
        {    
                WriteWordLine 3 0 "Shortcuts"                                   WriteWordLine 3 0 "Virtual Desktop"
     
                $ScriptInformation = New-Object System.Collections.ArrayList    
                If($PubItem.InheritShortcutDefaultSettings)    
                {    
                        $ScriptInformation.Add(@{Data = "Create shortcut on Desktop"; Value = $DefaultCreateShortcutOnDesktop; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Create shortcut in Start Folder"; Value = $DefaultCreateShortcutInStartFolder; }) > $Null    
                        If($DefaultCreateShortcutInStartFolder)    
                        {    
                                $ScriptInformation.Add(@{Data = ""; Value = $DefaultStartPath; }) > $Null    
                        }    
                        $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = $DefaultCreateShortcutInStartUpFolder; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $DefaultReplicateShortcutSettings.ToString(); }) > $Null    
     
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitContent;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                }    
                Else    
                {    
                        $ScriptInformation.Add(@{Data = "Create shortcut on Desktop"; Value = $PubItem.CreateShortcutOnDesktop; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Create shortcut in Start Folder"; Value = $PubItem.CreateShortcutInStartFolder; }) > $Null    
                        If($PubItem.CreateShortcutInStartFolder)    
                        {    
                                $ScriptInformation.Add(@{Data = ""; Value = $PubItem.StartPath; }) > $Null    
                        }    
                        $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = $PubItem.CreateShortcutInStartUpFolder; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateShortcutSettings.ToString(); }) > $Null    
     
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitContent;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                }    
                WriteWordLine 0 0 ""    
        }    
        If($OutputType -eq "Text")    
        {    
                Line 2 "Shortcuts"    
     
                If($PubItem.InheritShortcutDefaultSettings)    
                {    
                        Line 3 "Create shortcut on Desktop`t`t`t`t: " $DefaultCreateShortcutOnDesktop    
                        Line 3 "Create shortcut in Start Folder`t`t`t`t: " $DefaultCreateShortcutInStartFolder    
                        If($DefaultCreateShortcutInStartFolder)    
                        {    
                                Line 4 $DefaultStartPath    
                        }    
                        Line 3 "Create shortcut in Auto Start Folder`t`t`t: " $DefaultCreateShortcutInStartUpFolder    
                        Line 3 "Settings are replicated to all Sites`t`t`t: " $DefaultReplicateShortcutSettings.ToString()    
                }    
                Else    
                {    
                        Line 3 "Create shortcut on Desktop`t`t`t`t: " $PubItem.CreateShortcutOnDesktop    
                        Line 3 "Create shortcut in Start Folder`t`t`t`t: " $PubItem.CreateShortcutInStartFolder    
                        If($PubItem.CreateShortcutInStartFolder)    
                        {    
                                Line 4 $PubItem.StartPath    
                        }    
                        Line 3 "Create shortcut in Auto Start Folder`t`t`t: " $PubItem.CreateShortcutInStartUpFolder    
                        Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateShortcutSettings.ToString()    
                }    
                Line 0 ""    
        }    
        If($OutputType -eq "HTML")    
        {    
                WriteHTMLLine 3 0 "Shortcuts"    
     
                $rowdata = @()    
                If($PubItem.InheritShortcutDefaultSettings)    
                {    
                        $columnHeaders = @("Create shortcut on Desktop",($Script:htmlsb),$DefaultCreateShortcutOnDesktop.ToString(),$htmlwhite)    
                        $rowdata += @(,("Create shortcut in Start Folder",($Script:htmlsb),$DefaultCreateShortcutInStartFolder.ToString(),$htmlwhite))    
                        If($DefaultCreateShortcutInStartFolder)    
                        {    
                                $rowdata += @(,("",($Script:htmlsb),$DefaultStartPath,$htmlwhite))    
                        }    
                        $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),$DefaultCreateShortcutInStartUpFolder.ToString(),$htmlwhite))    
                        $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$DefaultReplicateShortcutSettings.ToString(),$htmlwhite))    
     
                        $msg = ""    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders    
                }    
                Else    
                {    
                        $columnHeaders = @("Create shortcut on Desktop",($Script:htmlsb),$PubItem.CreateShortcutOnDesktop.ToString(),$htmlwhite)    
                        $rowdata += @(,("Create shortcut in Start Folder",($Script:htmlsb),$PubItem.CreateShortcutInStartFolder.ToString(),$htmlwhite))    
                        If($PubItem.CreateShortcutInStartFolder)    
                        {    
                                $rowdata += @(,("",($Script:htmlsb),$PubItem.StartPath,$htmlwhite))    
                        }    
                        $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),$PubItem.CreateShortcutInStartUpFolder.ToString(),$htmlwhite))    
                        $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ReplicateShortcutSettings.ToString(),$htmlwhite))    
     
                        $msg = ""    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders    
                }    
                WriteHTMLLine 0 0 ""    
        }    
}    
#endregion    
     
#region process universal printing    
Function ProcessUniversalPrinting    
{    
        Param([object]$Site)    
            
        Write-Verbose "$(Get-Date -Format G): Processing Universal Printing"    
            
        OutputUniversalPrintingSectionPage    
            
        Write-Verbose "$(Get-Date -Format G): `tProcessing Universal Printing"    
            
        $RASPrinterSettings = Get-RASPrintingSettings -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Universal Printing information    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Universal Printing information"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Universal Printing information"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Universal Printing information"    
                }    
        }    
        ElseIf($? -and $null -eq $RASPrinterSettings)    
        {    
                Write-Host "    
                No Universal Printing information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Universal Printing information was found"    
                }    
                If($Text)    
                {    
                        Line 0 "No Universal Printing information was found"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Universal Printing information was found"    
                }    
        }    
        Else    
        {    
                $Printingobj = [PSCustomObject] @{    
                        PrinterNamePattern = $RASPrinterSettings.PrinterNamePattern    
                        ReplicateSettings  = $RASPrinterSettings.ReplicatePrinterPattern    
                        PrinterRetention   = $RASPrinterSettings.PrinterRetention    
                }    
                    
                $results = Get-RASRDS -SiteId $Site.Id -EA 0 4>$Null    
                    
                If(!($?))    
                {    
                        Write-Warning "    
                        `n    
                        Unable to retrieve RDS Printing information    
                        "    
                        $RDSobj = [PSCustomObject] @{    
                                Server = "None found"    
                                Type = "N/A"    
                                PrintingState = "N/A"    
                        }    
                }    
                ElseIf($? -and $null -eq $results)    
                {    
                Write-Host "    
                No RDS Printing information was found    
                " -ForegroundColor White    
                        $RDSobj = [PSCustomObject] @{    
                                Server = "None found"    
                                Type = "N/A"    
                                PrintingState = "N/A"    
                        }    
                }    
                Else    
                {    
                        $RDSobj = [PSCustomObject] @{    
                                Server = $Results.Server    
                                Type = "RD Session Hosts"    
                                PrintingState = $Results.EnablePrinting    
                        }    
                }    
                    
                $results = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null    
                    
                If(!($?))    
                {    
                        Write-Warning "    
                        `n    
                        Unable to retrieve VDI Hosts Printing information    
                        "    
                            
                        $VDIHostsobj = [PSCustomObject] @{    
                                Server = "Unable to retrieve"    
                                Type = "N/A"    
                                PrintingState = "N/A"    
                        }    
                }    
                ElseIf($? -and $null -eq $results)    
                {    
                Write-Host "    
                No VDI Hosts Printing information was found    
                " -ForegroundColor White    
                        $VDIHostsobj = [PSCustomObject] @{    
                                Server = "None found"    
                                Type = "N/A"    
                                PrintingState = "N/A"    
                        }    
                }    
                Else    
                {    
                        $VDIHostsobj = [PSCustomObject] @{    
                                Server = $Results.Server    
                                Type = "VDI Providers"    
                                PrintingState = $Results.EnablePrinting    
                        }    
                }    
                    
                OutputUniversalPrintingSettings $Printingobj $RDSobj $VDIHostsobj    
                    
                OutputUniversalPrinterDriversSettings $RASPrinterSettings    
                    
                OutputUniversalPrinterFontsSettings $RASPrinterSettings    
        }    
}    
     
Function OutputUniversalPrintingSectionPage    
{    
        If($MSWord -or $PDF)    
        {    
                $Script:Selection.InsertNewPage()    
                WriteWordLine 1 0 "Universal Printing"    
        }    
        If($Text)    
        {    
                Line 0 "Universal Printing"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 1 0 "Universal Printing"    
        }    
}    
     
Function OutputUniversalPrintingSettings    
{    
        Param([object]$Printingobj, [object]$RDSobj, [object]$VDIHostsobj)    
     
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Universal Printing"    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Universal Printing"    
        }    
        If($Text)    
        {    
                Line 1 "Universal Printing"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Universal Printing"    
        }    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 3 0 "Options"                                   WriteWordLine 4 0 "Virtual desktop"
        }    
        If($Text)    
        {    
                Line 2 "Options"    
        }    
        If($HTML)    
        {    
                #Nothing    
        }    
     
        If($MSWord -or $PDF)    
        {    
                $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                $ScriptInformation.Add(@{Data = "Printer rename pattern"; Value = $Printingobj.PrinterNamePattern; }) > $Null                                   $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null
                $ScriptInformation.Add(@{Data = "Printer retention"; Value = $Printingobj.PrinterRetention; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                $ScriptInformation.Add(@{Data = 'Settings are replicated to all Sites'; Value = $Printingobj.ReplicateSettings.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 275;                                   $Table.Columns.Item(2).Width = 300;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
        }    
        If($Text)    
        {    
                Line 3 "Printer rename pattern`t`t`t: " $Printingobj.PrinterNamePattern    
                Line 3 "Printer retention`t`t`t: " $Printingobj.PrinterRetention    
                Line 3 "Settings are replicated to all Sites`t: " $Printingobj.ReplicateSettings.ToString()    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @(    
                        "Printer rename pattern",($Script:htmlsb),    
                        $Printingobj.PrinterNamePattern,$htmlwhite    
                )    
                $rowdata += @(,(    
                        "Printer retention",($Script:htmlsb),    
                        $Printingobj.PrinterRetention.ToString(),$htmlwhite)    
                )    
                $rowdata += @(,(    
                        "Settings are replicated to all Sites",($Script:htmlsb),    
                        $Printingobj.ReplicateSettings.ToString(),$htmlwhite)    
                )    
 
                $msg = "Options" <>  
                $columnWidths = @("200","300")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 3 0 "Servers in site"                                   WriteWordLine 4 0 "Properties"
        }    
        If($Text)    
        {    
                Line 2 "Servers in site"    
        }    
        If($HTML)    
        {    
                #Nothing    
        }    
     
        Switch ($RDSobj.PrintingState)    
        {    
                $True   {$RDSPrintingState = "Enabled"; Break}    
                $False  {$RDSPrintingState = "Disabled"; Break}    
                "N/A"   {$RDSPrintingState = "N/A"; Break}    
                Default {$RDSPrintingState = "Unable to determine RD Sessions Hosts Printing State: $($RDSobj.PrintingState)"; Break}    
        }    
            
        Switch ($VDIHostsobj.PrintingState)    
        {    
                $True   {$VDIHostsPrintingState = "Enabled"; Break}    
                $False  {$VDIHostsPrintingState = "Disabled"; Break}    
                "N/A"   {$VDIHostsPrintingState = "N/A"; Break}    
                Default {$VDIHostsPrintingState = "Unable to determine VDI Hosts Printing State: $($VDIHostsobj.PrintingState)"; Break}    
        }    
     
        $RDSType = $RDSObj.Type    
        $VDIType = $VDIHostsObj.Type    
            
        If($MSWord -or $PDF)    
        {    
                $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                $ServersInSiteTable = @()    
                    
                ForEach($RDSServer in $RDSobj.Server)    
                {    
                        $ServersInSiteTable += @{    
                                Server = $RDSServer    
                                Type   = $RDSType    
                                State  = $RDSPrintingState    
                        }    
                }    
                    
                ForEach($VDIServer in $VDIHostsobj.Server)    
                {    
                        $ServersInSiteTable += @{    
                                Server = $VDIServer    
                                Type   = $VDIType    
                                State  = $VDIHostsPrintingState    
                        }    
                }    
     
                If($ServersInSiteTable.Count -gt 0)    
                {    
                        $Table = AddWordTable -Hashtable $ServersInSiteTable `    
                        -Columns Server, Type, State `    
                        -Headers "Server", "Type", "State" `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 200;    
                        $Table.Columns.Item(2).Width = 100;    
                        $Table.Columns.Item(3).Width = 100;    
                            
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                   $ScriptInformation.Add(@{Data = "Connect to"; Value = $ConnectTo; }) > $Null
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
                }    
        }    
        If($Text)    
        {    
                Line 3 "Server                         Type                 State   "    
                Line 3 "============================================================"    
                #       123456789012345678901234567890S12345678901234567890S12345678    
     
                ForEach($RDSServer in $RDSobj.Server)    
                {    
                        Line 3 ( "{0,-30} {1,-20} {2,-8}" -f     
                                $RDSServer,     
                                $RDSType,     
                                $RDSPrintingState    
                        )    
                }    
                    
                ForEach($VDIServer in $VDIHostsobj.Server)    
                {    
                        Line 3 ( "{0,-30} {1,-20} {2,-8}" -f     
                                $VDIServer,     
                                $VDIType,     
                                $VDIHostsPrintingState    
                        )    
                }    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                $rowdata = @()    
     
                ForEach($RDSServer in $RDSobj.Server)    
                {    
                        $rowdata += @(,(    
                                $RDSServer,$htmlwhite,    
                                $RDSType,$htmlwhite,    
                                $RDSPrintingState,$htmlwhite)    
                        )    
                }    
                    
                ForEach($VDIServer in $VDIHostsobj.Server)    
                {    
                        $rowdata += @(,(    
                                $VDIServer,$htmlwhite,    
                                $VDIType,$htmlwhite,    
                                $VDIHostsPrintingState,$htmlwhite)    
                        )    
                }    
                    
                $columnHeaders = @(    
                        "Server",($Script:htmlsb),    
                        "Type",($Script:htmlsb),    
                        "State",($Script:htmlsb)    
                )    
     
                $msg = "Servers in site"    
                $columnWidths = @("200","100","100")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
}    
     
Function OutputUniversalPrinterDriversSettings     
{    
        Param([object] $RASPrinterSettings)    
     
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Printer drivers"    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Printer drivers"    
        }    
        If($Text)    
        {    
                Line 1 "Printer drivers"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Printer drivers"    
        }    
     
        Switch ($RASPrinterSettings.DriverAllowMode)    
        {    
                "AllowRedirUsingAnyDriver"    
                        {$RASPrinterSettingsDriverAllowMode = "Allow redirection of printers using any driver"; Break}    
                "AllowRedirUsingSpecifiedDriver"    
                        {$RASPrinterSettingsDriverAllowMode = "Allow redirection of printers using one of the following drivers"; Break}    
                "DoNotAllowRedirUsingSpecifiedDriver"    
                        {$RASPrinterSettingsDriverAllowMode = "Don't allow redirection of printers that use one of the following drivers"; Break}    
                Default    
                        {$RASPrinterSettingsDriverAllowMode = "Unable to determine RAS Printer Setting Driver Allow Mode: $($RASPrinterSettings.DriverAllowMode)"; Break}    
        }    
            
        If($RASPrinterSettingsDriverAllowMode -eq "Allow redirection of printers using any driver")    
        {    
                If($MSWord -or $PDF)    
                {    
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $ScriptInformation.Add(@{Data = "Mode"; Value = $RASPrinterSettingsDriverAllowMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASPrinterSettings.ReplicatePrinterDrivers.ToString(); }) > $Null    
     
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 100;    
                        $Table.Columns.Item(2).Width = 275;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
                }    
                If($Text)    
                {    
                        Line 2 "Mode: " $RASPrinterSettingsDriverAllowMode    
                        Line 2 "Settings are replicated to all Sites: " $RASPrinterSettings.ReplicatePrinterDrivers.ToString()    
                        Line 0 ""    
                }    
                If($HTML)    
                {    
                        $rowdata = @()    
                        $columnHeaders = @("Mode",($Script:htmlsb),$RASPrinterSettingsDriverAllowMode,$htmlwhite)    
                        $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASPrinterSettings.ReplicatePrinterDrivers.ToString(),$htmlwhite))    
     
                        $msg = ""    
                        $columnWidths = @("100","300")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }    
        }    
        Else    
        {    
                $tmpArray = $RASPrinterSettings.PrinterDriversArray.Split(",")    
                    
                If($MSWord -or $PDF)    
                {    
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $ScriptInformation.Add(@{Data = "Mode"; Value = $RASPrinterSettingsDriverAllowMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "Multi-Monitor"; Value = $AllowMultiMonitor; }) > $Null
     
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 100;    
                        $Table.Columns.Item(2).Width = 275;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                   $ScriptInformation.Add(@{Data = "Persistent"; Value = $PubItem.Persistent.ToString(); }) > $Null
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
     
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $DriverNameTable = @()    
                            
                        ForEach($item in $tmpArray)    
                        {    
                                $DriverNameTable += @{DriverName = $item}    
                        }    
     
                        If($DriverNameTable.Count -gt 0)    
                        {    
                                $Table = AddWordTable -Hashtable $DriverNameTable `    
                                -Columns DriverName `    
                                -Headers "Driver name" `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 100;    
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>  
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
     
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASPrinterSettings.ReplicatePrinterDrivers.ToString(); }) > $Null    
     
                        $Table = AddWordTable -Hashtable $ScriptInformation `                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 100;                                   $Table.Columns.Item(2).Width = 300;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
     
                                    OutputPubItemFilters $PubItem "MSWordPDF"
                                    
                                    OutputPubItemShortcuts $PubItem "MSWordPDF" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
                }                           }
                If($Text)                           If($Text)
                {                           {
                        $maxLength = ($tmparray | Measure-Object -Property length -Maximum).Maximum    
                        Line 2 "Mode: " $RASPrinterSettingsDriverAllowMode    
                        Line 0 ""    
                        Line 2 "Driver name"                                   Line 2 "Information"
                        Line 2 ("=" * $maxLength)                                   Line 3 "Virtual Desktop`t`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
                                    Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description
                                    Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod
                                    Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate
                                    Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()
                                    Line 3 "Settings for Site $xSiteName"
                                    Line 3 "Connect to`t`t`t`t`t`t: " $ConnectTo
                                                          
                        ForEach($item in $tmpArray)                                   If($PubItem.Persistent)
                        {                                   {
                                Line 2 $item                                           Line 3 "Published item is persistent"
                        }                                   }
                        Line 0 ""                                  
                        Line 2 "Settings are replicated to all Sites: " $RASPrinterSettings.ReplicatePrinterDrivers.ToString()                                   Line 3 "Desktop Size`t`t`t`t`t`t: " $DesktopSize
                        Line 0 ""    
                }    
                If($HTML)                                   If($PubItem.InheritShortcutDefaultSettings)
                {                                   {
                        $rowdata = @()                                           If($DefaultCreateShortcutOnDesktop -eq "True")
                        $columnHeaders = @(    
                                "Mode",($Script:htmlsb),    
                                $RASPrinterSettingsDriverAllowMode,$htmlwhite    
                        )    
     
                        $msg = ""    
                        $columnWidths = @("100","300")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                            
                        $rowdata = @()    
     
                        ForEach($item in $tmpArray)    
                        {                                           {
                                $rowdata += @(,($item,$htmlwhite))                                                   Line 3 "Create shortcut on desktop"
                        }                                           }
                                                                  If($DefaultCreateShortcutInStartFolder -eq "True")
                        $columnHeaders = @(    
                                "Driver name",($Script:htmlsb)    
                        )                                           {
                                                    Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"
                        $msg = ""    
                        $columnWidths = @("100")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
     
                        $rowdata = @()    
                        $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$RASPrinterSettings.ReplicatePrinterDrivers.ToString(),$htmlwhite)    
     
                        $msg = ""    
                        $columnWidths = @("183","100")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }                                           }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    Line 3 "Create shortcut in Auto Start Folder"
        }                                           }
}                                   }
                                    Else
                                    {
Function OutputUniversalPrinterFontsSettings                                            If($PubItem.CreateShortcutOnDesktop)
{                                           {
                                                    Line 3 "Create shortcut on desktop"
                                            }
        Param([object] $RASFontsSettings)                                           If($PubItem.CreateShortcutInStartFolder)
                                            {
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Fonts"                                                   Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"
                                                  }
        If($MSWord -or $PDF)                                           If($PubItem.CreateShortcutInStartUpFolder)
        {                                           {
                WriteWordLine 2 0 "Fonts"                                                   Line 3 "Create shortcut in Auto Start Folder"
        }                                           }
                                    }
        If($Text)    
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
        {                                   {
                Line 1 "Fonts"                                           Line 3 "Own Filters"
        }                                   }
        If($HTML)    
                                    If($PubItem.UserFilterEnabled)
        {                                   {
                                            Line 3 " User filtering is enabled"
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                WriteHTMLLine 2 0 "Fonts"                                                   Line 10 "  " $Item.Account
        }                                           }
                                            Line 0 ""
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            Line 3 " IP filtering is enabled"
        If($RASFontsSettings.ExcludedFontsArray.Count -ne 0)                                           If($PubItem.AllowedIP4s.Count -gt 0)
        {                                           {
                $tmpArray1 = $RASFontsSettings.ExcludedFontsArray.Split(",")                                                   ForEach($item in $PubItem.AllowedIP4s)
                $tmpArray1 = $tmpArray1 | Sort-Object                                                   {
                #$maxLength = ($tmparray1 | Measure-Object -Property length -Maximum).Maximum                                                           If($item.From -eq $item.To)
                                                            {
                                                                    Line 10 "  " $item.From
        }                                                           }
        Else                                                           Else
        {                                                           {
                $tmpArray1 = @()                                                                   Line 10 "  $($item.From) - $($item.To)"
        }                                                           }
                                                    }
                                            }
 
        If($RASFontsSettings.AutoInstallFonts.Count -eq 0) <>                                         If($PubItem.AllowedIP6s.Count -gt 0)
        {                                           {
                $tmpArray2 = @()                                                   ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    Line 10 "  " $item.From
        }                                                           }
        Else                                                           Else
        {                                                           {
                $tmpArray2 = $RASFontsSettings.AutoInstallFonts.Split(",")                                                                   Line 10 "  $($item.From) - $($item.To)"
                $tmpArray2 = $tmpArray2 | Sort-Object                                                           }
                #$maxLength = ($tmparray2 | Measure-Object -Property length -Maximum).Maximum                                                   }
        }                                           }
                                            Line 0 ""
                                    }
        If($MSWord -or $PDF)                                   If($PubItem.ClientFilterEnabled)
        {                                   {
                $ScriptInformation = New-Object System.Collections.ArrayList                                           Line 3 " Client filtering is enabled"
                $ScriptInformation.Add(@{Data = "Transfer Fonts"; Value = $RASFontsSettings.EmbedFonts.ToString(); }) > $Null    
                                            
                If($RASFontsSettings.EmbedFonts)                                           ForEach($item in $PubItem.AllowedClients)
                {                                           {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                        If($tmpArray1.Count -ne 0)                                   If($PubItem.MACFilterEnabled)
                        {                                   {
                                $ScriptInformation.Add(@{Data = "     Exclude the following Fonts from embedding"; Value = ""; }) > $Null                                           Line 3 " MAC filtering is enabled"
                                $cnt = -1                                          
                                ForEach($item in $tmpArray1)                                           ForEach($item in $PubItem.AllowedMACs)
                                {                                           {
                                                    Line 10 "  " $Item
                                        $cnt++                                           }
                                            Line 0 ""
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            Line 3 " Gateway filtering is enabled"
 
                                        If($cnt -eq 0) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $ScriptInformation.Add(@{Data = "          Font name"; Value = $item; }) > $Null <>                                                 Line 10" $Item
 
  <>                                         Line 0 ""
                                        Else                                   }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            Line 3 " Client device operating system filtering is enabled"
                                            
                                            If($PubItem.AllowedOSes.Android)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null <>                                                 Line 10 "  Android"
 
  <>                                         
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    Line 10 "  Chrome OS"
                                }                                           }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    Line 10 "  iOS/iPadOS"
                        }                                           }
                        Else                                          
                                            If($PubItem.AllowedOSes.Linux)
                        {                                           {
                                $ScriptInformation.Add(@{Data = "     Exclude the following Fonts from embedding"; Value = "None"; }) > $Null                                                   Line 10Linux"
                        }                                           }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    Line 10 "  macOS"
                }                                           }
                                            
                If($tmpArray2.Count -eq 0)                                           If($PubItem.AllowedOSes.WebPortal)
                {                                           {
                        $ScriptInformation.Add(@{Data = "     Auto install fonts"; Value = "None"; }) > $Null                                                   Line 10RAS Web Portal"
                }                                           }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                Else                                           {
                                                    Line 10 "  Windows"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                {                                           {
                        $ScriptInformation.Add(@{Data = "     Auto install fonts"; Value = ""; }) > $Null                                                   Line 10Wyse"
                                            }
                                            Line 0 ""
                                    }
     
                        $cnt = -1                                   $cnt =-1
                        ForEach($item in $tmpArray2)                                   ForEach($Site in $PubItem.PublishToSite)
                        {                                   {
                                $cnt++                                           $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                                                          
                                If($cnt -eq 0)                                           If($cnt -eq 0)
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "          Font file"; Value = $item; }) > $Null                                                   Line 3 "Available in Site(s):`t`t`t`t`t" $SiteName
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null                                                   Line 10 $SiteName
                                }                                           }
                        }                                   }
                                    Line 0 ""
     
                                    Line 2 "Sites"
                                    Line 3 "This published item will be available from the following Sites"
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            Line 10 $SiteName
                }                                   }
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASFontsSettings.ReplicatePrinterFont.ToString(); }) > $Null    
                                    Line 0 ""
                $Table = AddWordTable -Hashtable $ScriptInformation `    
                -Columns Data,Value `    
                -List `    
                -Format $wdTableGrid `    
                -AutoFit $wdAutoFitFixed;    
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 Line 2 "Virtual Desktop"
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   Line 3 "Virtual desktop"
                                    Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name
                $Table.Columns.Item(1).Width = 220;                                   Line 4 "Description`t`t`t`t`t: " $PubItem.Description
                $Table.Columns.Item(2).Width = 200;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                   Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()
                                    Line 0 ""
                FindWordDocumentEnd    
                $Table = $Null    
                WriteWordLine 0 0 ""                                   Line 3 "Properties"
                                    Line 4 "Connect to`t`t`t`t`t: " $ConnectTo
                                    Line 4 "Desktop Size`t`t`t`t`t: " $DesktopSize
                                    Line 4 "Multi-Monitor`t`t`t`t`t: " $AllowMultiMonitor
                                    Line 4 "Persistent`t`t`t`t`t: " $PubItem.Persistent.ToString()
                                    Line 0 ""
     
                                    OutputPubItemFilters $PubItem "Text"
                                    
                                    OutputPubItemShortcuts $PubItem "Text" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
        }                           }
        If($Text)                           If($HTML)
        {                           {
                Line 2 "Transfer Fonts: " $RASFontsSettings.EmbedFonts.ToString()                                   WriteHTMLLine 3 0 "Information"
                                    $rowdata = @()
     
                                    $columnHeaders = @("Virtual Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("Connect to",($Script:htmlsb),$ConnectTo,$htmlwhite))
                                    
                If($RASFontsSettings.EmbedFonts)                                   If($PubItem.Persistent)
                {                                   {
                        If($tmpArray1.Count -ne 0)                                           $rowdata += @(,("Published item is persistent",($Script:htmlsb),"",$htmlwhite))
                                    }
                                    
                                    $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))
     
                                    If($PubItem.InheritShortcutDefaultSettings)
                        {                                   {
                                Line 3 "Exclude the following Fonts from embedding"                                           If($DefaultCreateShortcutOnDesktop -eq "True")
                                $cnt = -1    
                                ForEach($item in $tmpArray1)    
                                {                                           {
                                                    $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                        $cnt++                                           }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                                                                  {
                                        If($cnt -eq 0)                                                   $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
 
                                                Line 4 "Font name: " $item <>                                                 $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
 
  <>                                 }
                                        Else                                   Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
 
                                                Line 5 "   " $item <>                                                 $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
 
  -+                                         If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                            }
 
  <>  
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))
                        }                                   }
                        Else    
                                    If($PubItem.UserFilterEnabled)
                        {                                   {
                                Line 3 "Exclude the following Fonts from embedding" "None"                                           $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))
                        }                                           }
                }                                   }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))
 
                If($tmpArray2.Count -eq 0) <>                                         If($PubItem.AllowedIP4s.Count -gt 0)
                {                                           {
                        Line 3 "Auto install fonts" "None"                                                   ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                }                                                           }
                Else                                                           Else
                {                                                           {
                        Line 3 "Auto install fonts"                                                                   $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                                            }
                                                    }
                                            }
                        $cnt = -1    
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                        ForEach($item in $tmpArray2)                                                   ForEach($item in $PubItem.AllowedIP6s)
                        {                                                   {
                                $cnt++                                                           If($item.From -eq $item.To)
                                    
                                If($cnt -eq 0)    
                                {                                                           {
                                        Line 4 "Font file: " $item                                                                   $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                }                                                           }
                                Else                                                           Else
                                {                                                           {
                                        Line 5 "   " $item                                                                   $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                }                                                           }
                        }                                                   }
                }                                           }
                Line 2 "Settings are replicated to all Sites: " $RASFontsSettings.ReplicatePrinterFont.ToString()    
                Line 0 ""    
        }                                   }
        If($HTML)                                   If($PubItem.ClientFilterEnabled)
        {                                   {
                $rowdata = @()    
                $columnHeaders = @("Transfer Fonts",($Script:htmlsb),$RASFontsSettings.EmbedFonts.ToString(),$htmlwhite)                                           $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                If($RASFontsSettings.EmbedFonts)                                           ForEach($item in $PubItem.AllowedClients)
                {                                           {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                        If($tmpArray1.Count -ne 0)                                   If($PubItem.MACFilterEnabled)
                        {                                   {
                                $rowdata += @(,("     Exclude the following Fonts from embedding",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                $cnt = -1                                          
                                ForEach($item in $tmpArray1)                                           ForEach($item in $PubItem.AllowedMACs)
                                {                                           {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                        $cnt++                                           }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))
 
                                        If($cnt -eq 0) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("          Font name",($Script:htmlsb),$item,$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
 
                                        Else <>                                 }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            If($PubItem.AllowedOSes.Android)
 
                                                $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))
 
  <>                                         
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
                                }                                           }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
                        }                                           }
                        Else                                          
                                            If($PubItem.AllowedOSes.Linux)
                        {                                           {
                                $rowdata += @(,("     Exclude the following Fonts from embedding",($Script:htmlsb),"None",$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))
                        }                                           }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))
                }                                           }
                                            
                If($tmpArray2.Count -eq 0)                                           If($PubItem.AllowedOSes.WebPortal)
                {                                           {
                        $rowdata += @(,("     Auto install fonts",($Script:htmlsb),"None",$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
                }                                           }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                Else                                           {
                                                    $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                {                                           {
                        $rowdata += @(,("     Auto install fonts",($Script:htmlsb),"",$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))
                                            }
                                    }
     
                        $cnt = -1                                   $cnt =-1
                        ForEach($item in $tmpArray2)                                   ForEach($Site in $PubItem.PublishToSite)
                        {                                   {
                                $cnt++                                           $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                                                          
                                If($cnt -eq 0)                                           If($cnt -eq 0)
                                {                                           {
                                        $rowdata += @(,("          Font file",($Script:htmlsb),$item,$htmlwhite))                                                   $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                                            }
 
  <>                         
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Sites"
                                    $rowdata = @()
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)
                        }                                           }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                }                                           }
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASFontsSettings.ReplicatePrinterFont.ToString(),$htmlwhite))                                   }
 
                $msg = "" <>                                 $msg = ""
                $columnWidths = @("260","220")                                   $columnWidths = @("200","300")
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Virtual Desktop"
                                    $rowdata = @()
     
                                    $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
     
                                    $msg = "Desktop"
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                                    
                                    $rowdata = @()
                                    $columnHeaders = @("Connect to",($Script:htmlsb),$ConnectTo,$htmlwhite)
                                    $rowdata += @(,("Desktop size",($Script:htmlsb),$DesktopSize,$htmlwhite))
                                    $rowdata += @(,("Multi-Monitor",($Script:htmlsb),$AllowMultiMonitor,$htmlwhite))
                                    $rowdata += @(,("Persistent",($Script:htmlsb),$PubItem.Persistent.ToString(),$htmlwhite))
     
                                    $msg = "Properties"
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    OutputPubItemFilters $PubItem "HTML"
                                    
                                    OutputPubItemShortcuts $PubItem "HTML" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
        }                           }
}                   }
#endregion                   ElseIf($PubItem.Type -eq "WVDApp")
                    {
#region process universal scanning                           Switch ($PubItem.ConCurrentLicenses)
                            {
                                    0               {$ConCurrentLicenses = "Unlimited"; Break}
                                    Default {$ConCurrentLicenses = $PubItem.ConCurrentLicenses.ToString(); Break} 
                            }
                            
Function ProcessUniversalScanning                           Switch ($PubItem.DisableSessionSharing)
{                           {
                                    $False  {$SessionSharing = "Enabled"; Break}
                                    $True   {$SessionSharing = "Disabled"; Break}
                                    Default {$SessionSharing = "Unable to determine Session Sharing state: $($PubItem.DisableSessionSharing)"; Break}
                            }
                            
        Param([object]$Site)                           Switch ($PubItem.PublishFrom)
                                  {
        Write-Verbose "$(Get-Date -Format G): Processing Universal scanning"                                   "All"           {$PublishedFrom = "All Servers in Site"; Break}
                                    "Group"         {$PublishedFrom = "Server Groups:"; Break}
                                    "Server"        {$PublishedFrom = "Individual Servers:"; Break}
                                    Default         {$PublishedFrom = "Unable to determine Published From: $($PubItem.PublishFrom)"; Break}
                                  }
        OutputUniversalScanningSectionPage    
                                  
                            Switch ($PubItem.LicenseLimitNotify)
                            {
                                    "WarnUserAndNoStart"            {$LicenseLimitNotify ="Warn user and do not start"; Break}
        Write-Verbose "$(Get-Date -Format G): `tProcessing Universal Scanning"                                   "WarnUserAndStart"                      {$LicenseLimitNotify ="Warn user and start"; Break}
                                    "NotifyAdminAndStart"           {$LicenseLimitNotify ="Notify administrator and start"; Break}
                                    "NotifyUserAdminAndStart"       {$LicenseLimitNotify ="Notify user, administrator and start"; Break}
                                    "NotifyUserAdminAndNoStart"     {$LicenseLimitNotify ="Notify user, administrator and do not start"; Break}
                                    Default                                         {$LicenseLimitNotify ="Unable to determine If limit is exceeded: $($PubItem.LicenseLimitNotify)"; Break}
                                  }
        $results = Get-RASScanningSettings -SiteId $Site.Id -EA 0 4>$Null    
                                  
        If(!($?))                           Switch ($PubItem.ColorDepth)
        {                           {
                Write-Warning "                                   "Colors8Bit"            {$ColorDepth = "256 Colors"; Break}
                                    "Colors15Bit"           {$ColorDepth = "High Color (15 bit)"; Break}
                                    "Colors16Bit"           {$ColorDepth = "High Color (16 bit)"; Break}
                                    "Colors24Bit"           {$ColorDepth = "True Color (24 bit)"; Break}
                                    "Colors32Bit"           {$ColorDepth = "Highest Quality (32 bit)"; Break}
                                    "ClientSpecified"       {$ColorDepth = "Client Specified"; Break}
                                    Default                         {$ColorDepth = "Unable to determine Color Depth: $($PubItem.ColorDepth)"; Break}
                `n                           }
                Unable to retrieve Universal Scanning information    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Universal Scanning information"                                   WriteWordLine 3 0 "Information"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Windows Virtual Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
     
                                    If(![String]::IsNullOrEmpty($PubItem.Parameters))
                                    {
                                            $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null
                }                                   }
                If($Text)                                  
                                    If($PubItem.EnableFileExtensions)
                {                                   {
                        Line 0 "Unable to retrieve Universal Scanning information"                                           $ScriptInformation.Add(@{Data = "Associate the following file extensions"; Value = ""; }) > $Null
                                            ForEach($Item in $PubItem.FileExtensions)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                }                                           }
                If($HTML)                                   }
                                    
                                    If($PubItem.InheritLicenseDefaultSettings)
                {                                   {
                        WriteHTMLLine 0 0 "Unable to retrieve Universal Scanning information"                                           If($DefaultOneInstancePerUser)
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))
                }                                           }
                                            Else
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))
        }                                           }
        ElseIf($? -and $null -eq $results)                                           $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $DefaultConCurrentLicenses; }) > $Null
                                            $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $DefaultLicenseLimitNotify; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $DefaultDisableSessionSharing ; }) > $Null
                                    }
                                    Else
        {                                   {
                                            If($PubItem.OneInstancePerUser)
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))
                                            }
                Write-Host "                                           Else
                No Universal Scanning information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {                                           {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))
                                            }
                                            $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $ConCurrentLicenses; }) > $Null
                                            $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $LicenseLimitNotify; }) > $Null
                        WriteWordLine 0 0 "No Universal Scanning information was found"                                           $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $SessionSharing; }) > $Null
                }                                   }
     
                                    $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null
                                    
                                    If($PubItem.PublishFrom -eq "Server")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromServer)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    
                If($Text)                                                   If($cnt -eq 0)
                {                                                   {
                        Line 0 "No Universal Scanning information was found"                                                           $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null
                }                                                   }
                If($HTML)                                                   Else
                {                                                   {
                        WriteHTMLLine 0 0 "No Universal Scanning information was found"                                                           $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                }                                                   }
        }                                           }
                                    }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromGroup)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    If($cnt -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null
                                                    }
        Else                                                   Else
        {                                                   {
                $WIAobj = [PSCustomObject] @{                                                           $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                        WIANamePattern    = $Results.WIANamePattern    
                        ReplicateSettings = $Results.ReplicateWIAPattern    
                }                                                   }
                                                          }
                $TWAINobj = [PSCustomObject] @{    
                        TWAINNamePattern  = $Results.TWAINNamePattern    
                        ReplicateSettings = $Results.ReplicateTWAINPattern    
                }                                   }
                                    Else
                                                  {
                $results = Get-RASRDS -SiteId $Site.Id -EA 0 4>$Null                                           $ScriptInformation.Add(@{Data = "Published from"; Value = "All Servers in Site"; }) > $Null
                                                  }
                If(!($?))    
                                    If($PubItem.InheritShortcutDefaultSettings)
                {                                   {
                        Write-Warning "                                           If($DefaultCreateShortcutOnDesktop -eq "True")
                        `n    
                        Unable to retrieve RDS Scanning information    
                        "                                           {
                        $RDSobj = [PSCustomObject] @{                                                   $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                Server = "Unable to retrieve"    
                                Type = "N/A"    
                                WIAState = $False    
                                TWAINState = $False    
                        }                                           }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null
                }                                           }
                ElseIf($? -and $null -eq $results)                                           If($DefaultCreateShortcutInStartUpFolder -eq "True")
                {                                           {
                Write-Host "                                                   $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                No RDS Scanning information was found    
                " -ForegroundColor White    
                        $RDSobj = [PSCustomObject] @{    
                                Server = "Not found"    
                                Type = "Not found"    
                                WIAState = $False    
                                TWAINState = $False    
                        }                                           }
                }                                   }
                Else                                   Else
                {                                   {
                        $RDSobj = [PSCustomObject] @{                                           If($PubItem.CreateShortcutOnDesktop)
                                Server = $Results.Server                                           {
                                Type = "RD Session Hosts"                                                   $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                WIAState = $Results.EnableWIA    
                                TWAINState = $Results.EnableTWAIN    
                        }                                           }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null
                }                                           }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                                          {
                $results = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null                                                   $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                                          }
                                    }
                If(!($?))    
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                {                                   {
                        Write-Warning "                                           $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null
                                    }
                        `n    
                                    If($PubItem.UserFilterEnabled)
                                    {
                        Unable to retrieve VDI Hosts Scanning information                                           $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                        "                                           {
                        $VDIHostsobj = [PSCustomObject] @{                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null
                                Server = "Unable to retrieve"    
                                Type = "Unknown"    
                                WIAState = $False    
                                TWAINState = $False    
                        }                                           }
                }                                   }
                ElseIf($? -and $null -eq $results)                                   If($PubItem.IPFilterEnabled)
                {                                   {
                                            $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                Write-Host "                                                           Else
                No VDI Hosts Scanning information was found                                                           {
                " -ForegroundColor White                                                                   $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                        $VDIHostsobj = [PSCustomObject] @{                                                           }
                                Server = "None found"                                                   }
                                Type = "Unknown"    
                                WIAState = $False    
                                TWAINState = $False    
                        }                                           }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                }                                                           }
                Else                                                           Else
                {                                                           {
                        $VDIHostsobj = [PSCustomObject] @{                                                                   $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                Server = $Results.Server    
                                Type = "VDI Providers"    
                                WIAState = $Results.EnableWIA    
                                TWAINState = $Results.EnableTWAIN    
                        }                                                           }
                }                                                   }
                                                          }
                OutputUniversalScanningSettings $WIAobj $TWAINobj $RDSobj $VDIHostsobj    
        }                                   }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
}                                           }
                                    }
Function OutputUniversalScanningSectionPage                                   If($PubItem.MACFilterEnabled)
{                                   {
        If($MSWord -or $PDF)                                           $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
        {                                           {
                $Script:Selection.InsertNewPage()                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                WriteWordLine 1 0 "Universal Scanning"                                           }
        }                                   }
        If($Text)                                   If($PubItem.GatewayFilterEnabled)
        {                                   {
                Line 0 "Universal Scanning"                                           $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
        }                                           }
        If($HTML)                                   }
                                    If($PubItem.OSFilterEnabled)
        {                                   {
                WriteHTMLLine 1 0 "Universal Scanning"                                           $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null
        }                                           }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
}                                           }
                                            
Function OutputUniversalScanningSettings                                           If($PubItem.AllowedOSes.iOS)
{                                           {
 Param([object]$WIAobj, [object]$TWAINobj, [object]$RDSobj, [object]$VDIHostsobj)                                                   $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
                                            }
        Write-Verbose "$(Get-Date -Format G): `t`tOutput WIA"    
                                                  
        If($MSWord -or $PDF)                                           If($PubItem.AllowedOSes.Linux)
        {                                           {
                WriteWordLine 2 0 "WIA"                                                   $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null
        }                                           }
        If($Text)                                          
                                            If($PubItem.AllowedOSes.Mac)
        {                                           {
                Line 1 "WIA"                                                   $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null
        }                                           }
        If($HTML)                                          
                                            If($PubItem.AllowedOSes.WebPortal)
        {                                           {
                WriteHTMLLine 2 0 "WIA"                                                   $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
        }                                           }
                                                  
        If($MSWord -or $PDF)                                           If($PubItem.AllowedOSes.Windows)
        {                                           {
                WriteWordLine 3 0 "Scanner rename"                                                   $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null
        }                                           }
        If($Text)                                          
                                            If($PubItem.AllowedOSes.Wyse)
        {                                           {
                Line 2 "Scanner rename"                                                   $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null
        }                                           }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
        If($HTML)                                           If($cnt -eq 0)
        {                                           {
                #Nothing                                                   $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null
        }                                           }
                                            Else
        If($MSWord -or $PDF)    
        {                                           {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Sites"
                $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                $ScriptInformation.Add(@{Data = "Pattern"; Value = $WIAObj.WIANamePattern; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                $ScriptInformation.Add(@{Data = 'Settings are replicated to all Sites'; Value = $WIAObj.ReplicateSettings.ToString(); }) > $Null                                           }
                                    }
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 275;                                   $Table.Columns.Item(2).Width = 300;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
        }    
        If($Text)    
        {    
                Line 3 "Pattern`t`t`t`t`t: " $WIAObj.WIANamePattern    
                Line 3 "Settings are replicated to all Sites`t: " $WIAObj.ReplicateSettings.ToString()    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @(    
                        "Pattern",($Script:htmlsb),    
                        $WIAObj.WIANamePattern,$htmlwhite    
                )    
                $rowdata += @(,(    
                        "Settings are replicated to all Sites",($Script:htmlsb),    
                        $WIAobj.ReplicateSettings.ToString(),$htmlwhite)    
                )    
 
                $msg = "Scanner rename" <>  
                $columnWidths = @("200","300")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 3 0 "Servers in Site"                                   WriteWordLine 3 0 "Publish from"
        }    
        If($Text)    
        {    
                Line 2 "Servers in Site"    
        }    
        If($HTML)    
        {    
                #Nothing    
        }    
     
        $RDSType = $RDSObj.Type    
        $VDIType = $VDIHostsObj.Type    
            
        If($MSWord -or $PDF)    
        {    
                $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                $ServersInSiteTable = @()                                   If($PubItem.PublishFrom -eq "Server")
                    
                $cnt = -1    
                ForEach($RDSServer in $RDSobj.Server)    
                {                                   {
                        $cnt++    
                        $ServersInSiteTable += @{    
                                Server = $RDSServer    
                                Type   = $RDSType    
                                State  = $RDSobj.WIAState[$cnt].ToString()    
                        }    
                }    
                    
                $cnt = -1                                           $cnt = -1
                ForEach($VDIServer in $VDIHostsobj.Server)                                           ForEach($Item in $PubItem.PublishFromServer)
                {                                           {
                        $cnt++                                                   $cnt++
                        $ServersInSiteTable += @{    
                                Server = $VDIServer    
                                Type   = $VDIType    
                                State  = $VDIHostsobj.WIAState[$cnt].ToString()    
                        }                                                   
                }                                                   $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    
                If($ServersInSiteTable.Count -gt 0)                                                   If($cnt -eq 0)
                {                                                   {
                        $Table = AddWordTable -Hashtable $ServersInSiteTable `                                                           $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null
                        -Columns Server, Type, State `    
                        -Headers "Server", "Type", "State" `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 200;    
                        $Table.Columns.Item(2).Width = 100;    
                        $Table.Columns.Item(3).Width = 100;    
                            
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
                }                                                   }
        }                                                   Else
        If($Text)    
        {                                                   {
                Line 3 "Server                         Type                 State   "                                                           $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                Line 3 "============================================================"    
                #       123456789012345678901234567890S12345678901234567890S12345678    
                $cnt = -1    
                ForEach($RDSServer in $RDSobj.Server)    
                {    
                        $cnt++    
                        Line 3 ( "{0,-30} {1,-20} {2,-8}" -f     
                                $RDSServer,     
                                $RDSType,     
                                $RDSobj.WIAState[$cnt].ToString()    
                        )    
                }                                                   }
                    
                $cnt = -1    
                ForEach($VDIServer in $VDIHostsobj.Server)    
                {    
                        $cnt++    
                        Line 3 ( "{0,-30} {1,-20} {2,-8}" -f     
                                $VDIServer,     
                                $VDIType,     
                                $VDIHostsobj.WIAState[$cnt].ToString()    
                        )    
                }                                           }
                Line 0 ""    
        }                                   }
        If($HTML)                                   ElseIf($PubItem.PublishFrom -eq "Group")
        {                                   {
                $rowdata = @()    
     
                $cnt = -1                                           $cnt = -1
                ForEach($RDSServer in $RDSobj.Server)                                           ForEach($Item in $PubItem.PublishFromGroup)
                {                                           {
                        $cnt++                                                   $cnt++
                        $rowdata += @(,(    
                                $RDSServer,$htmlwhite,    
                                $RDSType,$htmlwhite,    
                                $RDSobj.WIAState[$cnt].ToString(),$htmlwhite)    
                        )                                                   
                }                                                   $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                                  
                $cnt = -1                                                   If($cnt -eq 0)
                ForEach($VDIServer in $VDIHostsobj.Server)    
                {                                                   {
                        $cnt++                                                           $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null
                        $rowdata += @(,(    
                                $VDIServer,$htmlwhite,    
                                $VDIType,$htmlwhite,    
                                $VDIHostsobj.WIAState[$cnt].ToString(),$htmlwhite)    
                        )    
                }                                                   }
                                                    Else
                $columnHeaders = @(    
                        "Server",($Script:htmlsb),    
                        "Type",($Script:htmlsb),    
                        "State",($Script:htmlsb)    
                )    
     
                $msg = "Servers in Site"    
                $columnWidths = @("200","100","100")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
     
        Write-Verbose "$(Get-Date -Format G): `t`tOutput TWAIN"    
            
        If($MSWord -or $PDF)    
        {                                                   {
                WriteWordLine 2 0 "TWAIN"                                                           $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
        }                                                   }
        If($Text)    
        {    
                Line 1 "TWAIN"    
        }                                           }
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "TWAIN"    
        }                                   }
                                          Else
        If($MSWord -or $PDF)    
        {                                   {
                WriteWordLine 3 0 "Scanner rename"                                           $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = ""; }) > $Null
        }                                   }
        If($Text)    
        {    
                Line 2 "Scanner rename"    
        }    
        If($HTML)    
        {    
                #Nothing    
        }    
     
        If($MSWord -or $PDF)    
        {    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Pattern"; Value = $TWAINobj.TWAINNamePattern; }) > $Null    
                $ScriptInformation.Add(@{Data = 'Settings are replicated to all Sites'; Value = $TWAINobj.ReplicateSettings.ToString(); }) > $Null    
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 275;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
                WriteWordLine 0 0 ""    
        }    
        If($Text)    
        {    
                Line 3 "Pattern`t`t`t`t`t: " $TWAINobj.TWAINNamePattern    
                Line 3 "Settings are replicated to all Sites`t: " $TWAINobj.ReplicateSettings.ToString()    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @(    
                        "Pattern",($Script:htmlsb),    
                        $TWAINobj.TWAINNamePattern,$htmlwhite    
                )    
                $rowdata += @(,(    
                        "Settings are replicated to all Sites",($Script:htmlsb),    
                        $TWAINobj.ReplicateSettings.ToString(),$htmlwhite)    
                )    
     
                $msg = "Scanner rename"    
                $columnWidths = @("200","300")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 3 0 "Servers in Site"    
        }    
        If($Text)    
        {    
                Line 2 "Servers in Site"    
        }    
        If($HTML)    
        {    
                #Nothing    
        }    
     
        If($MSWord -or $PDF)    
        {    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ServersInSiteTable = @()    
                    
                $cnt = -1    
                ForEach($RDSServer in $RDSobj.Server)    
                {    
                        $cnt++    
                        $ServersInSiteTable += @{    
                                Server = $RDSServer    
                                Type   = $RDSType    
                                State  = $RDSobj.TwainState[$cnt].ToString()    
                        }    
                }    
                    
                $cnt = -1    
                ForEach($VDIServer in $VDIHostsobj.Server)    
                {    
                        $cnt++    
                        $ServersInSiteTable += @{    
                                Server = $VDIServer    
                                Type   = $VDIType    
                                State  = $VDIHostsobj.TwainState[$cnt].ToString()    
                        }    
                }    
     
                If($ServersInSiteTable.Count -gt 0)    
                {    
                        $Table = AddWordTable -Hashtable $ServersInSiteTable `    
                        -Columns Server, Type, State `    
                        -Headers "Server", "Type", "State" `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 200;                                   $Table.Columns.Item(2).Width = 300;
                        $Table.Columns.Item(2).Width = 100;    
                        $Table.Columns.Item(3).Width = 100;    
                            
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                }    
        }    
        If($Text)    
        {    
                Line 3 "Server                         Type                 State   "    
                Line 3 "============================================================"    
                #       123456789012345678901234567890S12345678901234567890S12345678    
                $cnt = -1    
                ForEach($RDSServer in $RDSobj.Server)    
                {    
                        $cnt++    
                        Line 3 ( "{0,-30} {1,-20} {2,-8}" -f     
                                $RDSServer,     
                                $RDSType,     
                                $RDSobj.TwainState[$cnt].ToString()    
                        )    
                }    
                    
                $cnt = -1    
                ForEach($VDIServer in $VDIHostsobj.Server)    
                {    
                        $cnt++    
                        Line 3 ( "{0,-30} {1,-20} {2,-8}" -f     
                                $VDIServer,     
                                $VDIType,     
                                $VDIHostsobj.TwainState[$cnt].ToString()    
                        )    
                }    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                $rowdata = @()    
 
                $cnt = -1 <>  
                ForEach($RDSServer in $RDSobj.Server)    
                {    
                        $cnt++    
                        $rowdata += @(,(    
                                $RDSServer,$htmlwhite,    
                                $RDSType,$htmlwhite,    
                                $RDSobj.TwainState[$cnt].ToString(),$htmlwhite)    
                        )    
                }    
                    
                $cnt = -1    
                ForEach($VDIServer in $VDIHostsobj.Server)    
                {    
                        $cnt++    
                        $rowdata += @(,(    
                                $VDIServer,$htmlwhite,    
                                $VDIType,$htmlwhite,    
                                $VDIHostsobj.TwainState[$cnt].ToString(),$htmlwhite)    
                        )    
                }    
                    
                $columnHeaders = @(    
                        "Server",($Script:htmlsb),    
                        "Type",($Script:htmlsb),    
                        "State",($Script:htmlsb)    
                )    
     
                $msg = "Servers in Site"    
                $columnWidths = @("200","100","100")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
}    
#endregion    
     
#region process connection    
Function ProcessConnection    
{    
        Param([object]$Site)    
            
        Write-Verbose "$(Get-Date -Format G): Processing Connection"    
            
        OutputConnectionSectionPage    
            
        Write-Verbose "$(Get-Date -Format G): `tProcessing Authentication"    
            
        $results = Get-RASAuthSettings -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve authentication information    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve authentication information"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve authentication information"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve authentication information"    
                }    
        }    
        ElseIf($? -and $null -eq $results)    
        {    
                Write-Host "    
                No authentication information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No authentication information was found"    
                }    
                If($Text)    
                {    
                        Line 0 "No authentication information was found"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No authentication information was found"    
                }    
        }    
        Else    
        {    
                OutputRASAuthSettings $results    
        }    
     
        Write-Verbose "$(Get-Date -Format G): `tProcessing Settings"    
            
        $results = Get-RASSessionSetting -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve RAS Session settings information    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve RAS Session settings information"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve RAS Session settings information"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve RAS Session settings information"    
                }    
        }    
        ElseIf($? -and $null -eq $results)    
        {    
                Write-Host "    
                No RAS Session settings information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No RAS Session settings information was found"    
                }    
                If($Text)    
                {    
                        Line 0 "No RAS Session settings information was found"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No RAS Session settings information was found"    
                }    
        }    
        Else    
        {    
                OutputRASSessionSetting $results    
        }    
     
        Write-Verbose "$(Get-Date -Format G): `tProcessing Second level authentication"    
            
        $results = Get-RAS2FASetting -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Second level authentication information    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Second level authentication information"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Second level authentication information"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Second level authentication information"    
                }    
        }    
        ElseIf($? -and $null -eq $results)    
        {    
                Write-Host "    
                No Second level authentication information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Second level authentication information was found"    
                }    
                If($Text)    
                {    
                        Line 0 "No Second level authentication information was found"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Second level authentication information was found"    
                }    
        }    
        Else    
        {    
                Output2FASetting $results    
        }    
     
        Write-Verbose "$(Get-Date -Format G): `tProcessing Allowed devices"    
            
        $results = Get-RASAllowedDevicesSetting -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Allowed devices information    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Allowed devices information"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Allowed devices information"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Allowed devices information"    
                }    
        }    
        ElseIf($? -and $null -eq $results)    
        {    
                Write-Host "    
                No Allowed devices information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Allowed devices information was found"    
                }    
                If($Text)    
                {    
                        Line 0 "No Allowed devices information was found"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Allowed devices information was found"    
                }    
        }    
        Else    
        {    
                OutputRASAllowedDevicesSetting $results    
        }    
}    
     
Function OutputConnectionSectionPage    
{    
        If($MSWord -or $PDF)    
        {    
                $Script:Selection.InsertNewPage()    
                WriteWordLine 1 0 "Connection"                                   WriteWordLine 3 0 "Application"
        }    
        If($Text)    
        {    
                Line 0 "Connection"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 1 0 "Connection"    
        }    
}    
     
Function OutputRASAuthSettings    
{    
        Param([object] $RASAuthSettings)    
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Authentication"    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Authentication"                                   WriteWordLine 4 0 "Application"
        }    
        If($Text)    
        {    
                Line 1 "Authentication"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Authentication"    
        }    
            
        Switch ($RASAuthSettings.AuthType)    
        {    
                "UsernamePassword"                                      {$RASAuthSettingsAuthType = "Credentials"; Break}    
                "SmartCard"                                                     {$RASAuthSettingsAuthType = "Smart Card"; Break}    
                "UsernamePasswordOrSmartCard"           {$RASAuthSettingsAuthType = "Credentials, Smart Card"; Break}    
                "Web"                                                           {$RASAuthSettingsAuthType = "Web (SAML)"; Break}    
                "UsernamePassword, Web"                         {$RASAuthSettingsAuthType = "Credentials, Web (SAML)"; Break}    
                "SmartCard, Web"                                        {$RASAuthSettingsAuthType = "Smart Card, Web (SAML)"; Break}    
                "UsernamePasswordOrSmartCard, Web"      {$RASAuthSettingsAuthType = "Credentials, Smart Card, Web (SAML)"; Break}    
                Default                                                         {$RASAuthSettingsAuthType = "Unable to determine AuthType: $($RASAuthSettings.AuthType)"; Break}    
        }    
            
        If($MSWord -or $PDF)    
        {    
                $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                $ScriptInformation.Add(@{Data = "Allowed authentication types"; Value = $RASAuthSettingsAuthType; }) > $Null                                   $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null
                If($RASAuthSettings.AllTrustedDomains)    
                {    
                        $ScriptInformation.Add(@{Data = "Authentication domain"; Value = "All Trusted Domains"; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                }    
                Else    
                {    
                        $ScriptInformation.Add(@{Data = "Authentication domain"; Value = "Specific: $($RASAuthSettings.Domain)"; }) > $Null                                   $ScriptInformation.Add(@{Data = "Run"; Value = $WinType; }) > $Null
                }    
                $ScriptInformation.Add(@{Data = "Use client domain if specified"; Value = $RASAuthSettings.UseClientDomain.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null
                $ScriptInformation.Add(@{Data = 'Force clients to use NetBIOS credentials'; Value = $RASAuthSettings.ForceNetBIOSCreds.ToString(); }) > $Null    
                $ScriptInformation.Add(@{Data = 'Settings are replicated to all Sites'; Value = $RASAuthSettings.ReplicateSettings.ToString(); }) > $Null    
     
                $Table = AddWordTable -Hashtable $ScriptInformation `    
                -Columns Data,Value `    
                -List `    
                -Format $wdTableGrid `    
                -AutoFit $wdAutoFitFixed;    
     
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                $Table.Columns.Item(1).Width = 250;    
                $Table.Columns.Item(2).Width = 175;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
                WriteWordLine 0 0 ""    
        }    
        If($Text)    
        {    
                Line 2 "Allowed authentication types`t`t`t: " $RASAuthSettingsAuthType    
                If($RASAuthSettings.AllTrustedDomains)    
                {    
                        Line 2 "All Trusted Domains" ""    
                }    
                Else    
                {    
                        Line 2 "Domain`t`t`t`t`t`t: " $RASAuthSettings.Domain    
                }    
                Line 2 "Use client domain if specified`t`t`t: " $RASAuthSettings.UseClientDomain.ToString()    
                Line 2 "Force clients to use NetBIOS credentials`t: " $RASAuthSettings.ForceNetBIOSCreds.ToString()    
                Line 2 "Settings are replicated to all Sites`t`t: " $RASAuthSettings.ReplicateSettings.ToString()    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @("Allowed authentication types",($Script:htmlsb),$RASAuthSettingsAuthType,$htmlwhite)    
                If($RASAuthSettings.AllTrustedDomains)    
                {    
                        $rowdata += @(,("All Trusted Domains",($Script:htmlsb),"",$htmlwhite))    
                }    
                Else    
                {    
                        $rowdata += @(,("Domain",($Script:htmlsb),$RASAuthSettings.Domain,$htmlwhite))    
                }    
                $rowdata += @(,("Use client domain if specified",($Script:htmlsb),$RASAuthSettings.UseClientDomain.ToString(),$htmlwhite))    
                $rowdata += @(,("Force clients to use NetBIOS credentials",($Script:htmlsb),$RASAuthSettings.ForceNetBIOSCreds.ToString(),$htmlwhite))    
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASAuthSettings.ReplicateSettings.ToString(),$htmlwhite))    
     
                $msg = ""    
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
}    
     
Function OutputRASSessionSetting    
{    
        Param([object] $RASSessionSettings)    
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Settings"    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Settings"    
        }    
        If($Text)    
        {    
                Line 1 "Settings"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Settings"    
        }    
            
        Switch ($RASSessionSettings.RemoteIdleSessionTimeout)    
        {    
                60              {$RemoteIdleSessionTimeout = "1 minute"; Break}    
                180             {$RemoteIdleSessionTimeout = "3 minutes"; Break}    
                300             {$RemoteIdleSessionTimeout = "5 minutes"; Break}    
                600             {$RemoteIdleSessionTimeout = "10 minutes"; Break}    
                1800    {$RemoteIdleSessionTimeout = "30 minutes"; Break}    
                3600    {$RemoteIdleSessionTimeout = "1 hour"; Break}    
                5400    {$RemoteIdleSessionTimeout = "1 hour, 30 minutes"; Break}    
                7200    {$RemoteIdleSessionTimeout = "2 hours"; Break}    
                21600   {$RemoteIdleSessionTimeout = "6 hours"; Break}    
                43200   {$RemoteIdleSessionTimeout = "12 hours"; Break}    
                86400   {$RemoteIdleSessionTimeout = "1 day"; Break}    
                Default {$RemoteIdleSessionTimeout = "Unable to determine idle session timeout: $($RASSessionSettings.RemoteIdleSessionTimeout)"; Break}    
        }    
            
        Switch ($RASSessionSettings.LogoffIdleSessionTimeout)    
        {    
                0               {$LogoffIdleSessionTimeout = "Never"; Break}    
                300             {$LogoffIdleSessionTimeout = "5 minutes"; Break}    
                600             {$LogoffIdleSessionTimeout = "10 minutes"; Break}    
                900             {$LogoffIdleSessionTimeout = "15 minutes"; Break}    
                1200    {$LogoffIdleSessionTimeout = "20 minutes"; Break}    
                1800    {$LogoffIdleSessionTimeout = "30 minutes"; Break}    
                3600    {$LogoffIdleSessionTimeout = "1 hour"; Break}    
                Default {$LogoffIdleSessionTimeout = "Unable to determine idle session logoff: $($RASSessionSettings.LogoffIdleSessionTimeout)"; Break}    
        }    
            
        Switch ($RASSessionSettings.CachedSessionTimeout)    
        {    
                60              {$CachedSessionTimeout = "1 minute"; Break}    
                180             {$CachedSessionTimeout = "3 minutes"; Break}    
                300             {$CachedSessionTimeout = "5 minutes"; Break}    
                600             {$CachedSessionTimeout = "10 minutes"; Break}    
                1800    {$CachedSessionTimeout = "30 minutes"; Break}    
                3600    {$CachedSessionTimeout = "1 hour"; Break}    
                5400    {$CachedSessionTimeout = "1 hour, 30 minutes"; Break}    
                7200    {$CachedSessionTimeout = "2 hours"; Break}    
                21600   {$CachedSessionTimeout = "6 hours"; Break}    
                43200   {$CachedSessionTimeout = "12 hours"; Break}    
                86400   {$CachedSessionTimeout = "1 day"; Break}    
                86400   {$CachedSessionTimeout = "30 days"; Break}    
                Default {$CachedSessionTimeout = "Unable to determine cached session timeout: $($RASSessionSettings.CachedSessionTimeout)"; Break}    
        }    
            
        If($MSWord -or $PDF)    
        {    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Declare remote session idle after"; Value = $RemoteIdleSessionTimeout; }) > $Null                                   $ScriptInformation.Add(@{Data = "Start in"; Value = $PubItem.StartIn; }) > $Null
                $ScriptInformation.Add(@{Data = "Automatic logoff RAS idle session after"; Value = $LogoffIdleSessionTimeout; }) > $Null                                   $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
                $ScriptInformation.Add(@{Data = "Cached Session Timeout"; Value = $CachedSessionTimeout; }) > $Null                                   $ScriptInformation.Add(@{Data = "Exclude from session prelaunch"; Value = $PubItem.ExcludePrelaunch.ToString(); }) > $Null
                $ScriptInformation.Add(@{Data = 'FIPS 140-2 encryption'; Value = $RASSessionSettings.FIPSMode; }) > $Null    
                $ScriptInformation.Add(@{Data = 'Settings are replicated to all Sites'; Value = $RASSessionSettings.ReplicateSettings.ToString(); }) > $Null    
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 175;                                   $Table.Columns.Item(2).Width = 300;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
        }    
        If($Text)    
        {    
                Line 2 "Declare remote session idle after`t: " $RemoteIdleSessionTimeout    
                Line 2 "Automatic logoff RAS idle session after`t: " $LogoffIdleSessionTimeout    
                Line 2 "Cached Session Timeout`t`t`t: " $CachedSessionTimeout    
                Line 2 "FIPS 140-2 encryption`t`t`t: " $RASSessionSettings.FIPSMode    
                Line 2 "Settings are replicated to all Sites`t: " $RASSessionSettings.ReplicateSettings.ToString()    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @("Declare remote session idle after",($Script:htmlsb),$RemoteIdleSessionTimeout,$htmlwhite)    
                $rowdata += @(,("Automatic logoff RAS idle session after",($Script:htmlsb),$LogoffIdleSessionTimeout,$htmlwhite))    
                $rowdata += @(,("Cached Session Timeout",($Script:htmlsb),$CachedSessionTimeout,$htmlwhite))    
                $rowdata += @(,("FIPS 140-2 encryption",($Script:htmlsb),$RASSessionSettings.FIPSMode.ToString(),$htmlwhite))    
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASSessionSettings.ReplicateSettings.ToString(),$htmlwhite))    
     
                $msg = ""    
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
}    
     
Function Output2FASetting    
{    
        Param([object] $RAS2FASettings)    
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Second level authentication"    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Multi-factor authentication"    
        }    
        If($Text)    
        {    
                Line 1 "Multi-factor authentication"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Multi-factor authentication"    
        }    
     
        Switch ($RAS2FASettings.Provider)    
        {    
                "None"                  {$RAS2FASettingsProvider = "None"; Break}    
                "Deepnet"               {$RAS2FASettingsProvider = "Deepnet"; Break}    
                "SafeNet"               {$RAS2FASettingsProvider = "SafeNet"; Break}    
                "Radius"                {$RAS2FASettingsProvider = "RADIUS"; Break}    
                "AzureRadius"   {$RAS2FASettingsProvider = "Azure MFA server (RADIUS)"; Break}    
                "DuoRadius"     {$RAS2FASettingsProvider = "Duo (RADIUS)"; Break}    
                "FortiRadius"   {$RAS2FASettingsProvider = "FortiAuthenticator (RADIUS)"; Break}    
                "TekRadius"     {$RAS2FASettingsProvider = "TekRADIUS"; Break}    
                "GAuthTOTP"             {$RAS2FASettingsProvider = "Google Authenticator"; Break}    
                Default                 {$RAS2FASettingsProvider = "Unable to determine 2FA Provider: $($RAS2FASettings.Provider)"; Break}    
        }    
     
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 3 0 "Provider settings"    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Provider"; Value = $RAS2FASettingsProvider; }) > $Null    
                    
                If($RAS2FASettingsProvider -ne "None")    
                {    
                        $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null    
                            
                        If($RAS2FASettings.Provider -eq "AzureRadius")    
                        {    
                                $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.AzureRadiusSettings.TypeName; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.AzureRadiusSettings.Server; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.AzureRadiusSettings.BackupServer; }) > $Null    
                                If($RAS2FASettings.AzureRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.AzureRadiusSettings.Port; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.AzureRadiusSettings.Timeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.AzureRadiusSettings.Retries; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.AzureRadiusSettings.PasswordEncoding; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.AzureRadiusSettings.UsernameOnly.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.AzureRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "DuoRadius")    
                        {    
                                $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.DuoRadiusSettings.TypeName; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Primary Server"; Value = $RAS2FASettings.DuoRadiusSettings.Server; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Secondary Server"; Value = $RAS2FASettings.DuoRadiusSettings.BackupServer; }) > $Null    
                                If($RAS2FASettings.DuoRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.DuoRadiusSettings.Port; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.DuoRadiusSettings.Timeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.DuoRadiusSettings.Retries; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.DuoRadiusSettings.PasswordEncoding; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.DuoRadiusSettings.UsernameOnly.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.DuoRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "FortiRadius")    
                        {    
                                $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.FortiRadiusSettings.TypeName; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.FortiRadiusSettings.Server; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.FortiRadiusSettings.BackupServer; }) > $Null    
                                If($RAS2FASettings.FortiRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.FortiRadiusSettings.Port; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.FortiRadiusSettings.Timeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.FortiRadiusSettings.Retries; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.FortiRadiusSettings.PasswordEncoding; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.FortiRadiusSettings.UsernameOnly.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.FortiRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "TekRadius")    
                        {    
                                $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.TekRadiusSettings.TypeName; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.TekRadiusSettings.Server; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.TekRadiusSettings.BackupServer; }) > $Null    
                                If($RAS2FASettings.TekRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.TekRadiusSettings.Port; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.TekRadiusSettings.Timeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.TekRadiusSettings.Retries; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.TekRadiusSettings.PasswordEncoding; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.TekRadiusSettings.UsernameOnly.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.TekRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "Radius")    
                        {    
                                $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.RadiusSettings.TypeName; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.RadiusSettings.Server; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.RadiusSettings.BackupServer; }) > $Null    
                                If($RAS2FASettings.RadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.RadiusSettings.Port; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.RadiusSettings.Timeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.RadiusSettings.Retries; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.RadiusSettings.PasswordEncoding; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.RadiusSettings.UsernameOnly.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.RadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "Deepnet")    
                        {    
                                Switch($RAS2FASettings.DeepnetSettings.AuthMode)    
                                {    
                                        "MandatoryForAllUsers"                                          {$DeepNetAuthMode = "Mandatory for all users"; Break}    
                                        "CreateTokenForDomainAuthenticatedUsers"        {$DeepNetAuthMode = "Create token for Domain Authenticated users"; Break}    
                                        "UsersWithSafeNetAcc"                                           {$DeepNetAuthMode = "Use only for users with a safe account"; Break}    
                                        Default                                                                         {$DeepNetAuthMode = "Deepnet mode not found: $($RAS2FASettings.DeepnetSettings.AuthMode)"; Break}    
                                }    
 
                                $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null <>                                 OutputPubItemFilters $PubItem "MSWordPDF"
                                $ScriptInformation.Add(@{Data = "          Type"; Value = $RAS2FASettings.DeepnetSettings.DeepnetType; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Server"; Value = $RAS2FASettings.DeepnetSettings.Server; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.DeepnetSettings.Port.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Enable SSL"; Value = $RAS2FASettings.DeepnetSettings.SSL.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Agent"; Value = $RAS2FASettings.DeepnetSettings.DeepnetAgent; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Application"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Application"; Value = $RAS2FASettings.DeepnetSettings.App; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Domain"; Value = $RAS2FASettings.DeepnetSettings.DefaultDomain; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Mode"; Value = $DeepNetAuthMode; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Token Type"; Value = $RAS2FASettings.DeepnetSettings.TokenType.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Allow Channels"; Value = "Email: $($RAS2FASettings.DeepnetSettings.ActivateEmail.ToString())"; }) > $Null    
                                $ScriptInformation.Add(@{Data = "                        "; Value = "SMS: $($RAS2FASettings.DeepnetSettings.ActivateSMS.ToString())"; }) > $Null    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "SafeNet")    
                        {    
                                Switch($RAS2FASettings.SafeNetSettings.AuthMode)    
                                {    
                                        "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}    
                                        "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}    
                                        "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}    
                                        Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RAS2FASettings.SafeNetSettings.AuthMode)"; Break}    
                                }    
     
                                $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          OTP Service URL"; Value = $RAS2FASettings.SafeNetSettings.OTPServiceURL; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Mode"; Value = $SafeNetAuthMode; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          TMS Web API URL"; Value = $RAS2FASettings.SafeNetSettings.TMSWebApiURL; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          User Repository"; Value = $RAS2FASettings.SafeNetSettings.UserRepository; }) > $Null    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "GAuthTOTP")    
                        {    
                                Switch($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)    
                                {    
                                        "Allow"                 {$GAuthAllow = "Allow"; Break}    
                                        "AllowUntil"    {$GAuthAllow = "Allow until"; Break}    
                                        "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}    
                                        Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)"; Break}    
                                }    
 
  <>                                 OutputPubItemShortcuts $PubItem "MSWordPDF" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                Switch($RAS2FASettings.GAuthTOTPSettings.Tolerance)                                   $DefaultReplicateShortcutSettings
                                {    
                                        0               {$TOTPTolerance = "None"; Break}    
                                        30              {$TOTPTolerance = "+/- 30 seconds"; Break}    
                                        60              {$TOTPTolerance = "+/- 60 seconds"; Break}    
                                        90              {$TOTPTolerance = "+/- 90 seconds"; Break}    
                                        120             {$TOTPTolerance = "+/- 120 seconds"; Break}    
                                        Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}    
                                }    
                                    
                                $ScriptInformation.Add(@{Data = "     Type Name"; Value = $RAS2FASettings.GAuthTOTPSettings.Type; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     User Enrollment"; Value = ""; }) > $Null    
                                If($GAuthAllow -eq "Allow until")    
                                {    
                                        $GAuthFullDate = $RAS2FASettings.GAuthTOTPSettings.UntilDateTime    
                                        $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()    
                                        $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()    
                                        $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = "Date: $GAuthDate"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Time: $GAuthTime"; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = ""; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          TOTP tolerence"; Value = $TOTPTolerance; }) > $Null    
                        }    
 
                        If($RAS2FASettings.RestrictionMode -eq "Exclusion") <>  
                        {    
                                $ScriptInformation.Add(@{Data = "Enable MFA for all users except"; Value = ""; }) > $Null    
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "Disable MFA for all users except"; Value = ""; }) > $Null    
                        }    
                            
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 250;    
                        $Table.Columns.Item(2).Width = 175;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
     
                        WriteWordLine 3 0 "Restriction"                                   WriteWordLine 3 0 "File extensions"
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                        $ScriptInformation.Add(@{Data = "User or group list"; Value = $RAS2FASettings.ExcludeUserGroup.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Associate File Extensions"; Value = $PubItem.EnableFileExtensions.ToString(); }) > $Null
                        If($RAS2FASettings.ExcludeUserGroup)    
                        {    
                                If($RAS2FASettings.ExcludeUserGroupList.Count -gt 0)    
                                {    
                                        ForEach($Item in $RAS2FASettings.ExcludeUserGroupList)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "User: $($Item.Account)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Type: $($Item.Type)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                        }    
                                }    
                        }    
 
                        $ScriptInformation.Add(@{Data = "Client IP list"; Value = $RAS2FASettings.ExcludeClientIPs.ToString(); }) > $Null <>  
                        If($RAS2FASettings.ExcludeClientIPs)                                   If($PubItem.EnableFileExtensions)
                        {    
                                If($RAS2FASettings.ExcludeClientIPList.Count -gt 0)    
 
                                        $cnt     = -1 <>                                         $cnt = -1
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)    
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)    
     
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPList)                                           ForEach($Item in $PubItem.FileExtensions)
 
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To) +-  
 
                                                        $ScriptInformation.Add(@{Data = "     IPv4 Addresses"; Value = $tmp; }) > $Null <>  
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null                                                           $ScriptInformation.Add(@{Data = "Extension"; Value = $Item; }) > $Null
 
                                        } +-  
                                }    
                                    
                                If($RAS2FASettings.ExcludeClientIPv6List.Count -gt 0)    
                                {    
                                        $cnt     = -1    
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)    
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)    
     
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPv6List)    
                                        {    
                                                $cnt++    
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "     IPv6 Addresses"; Value = $tmp; }) > $Null    
                                                }    
 
                                                        $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null <>                                                         $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                                }    
                                        }    
                                }    
                        }    
     
                        $ScriptInformation.Add(@{Data = "Client MAC list"; Value = $RAS2FASettings.ExcludeClientMAC.ToString(); }) > $Null    
                        If($RAS2FASettings.ExcludeClientMAC)    
                        {    
                                $cnt = -1    
                                ForEach($MAC in $RAS2FASettings.ExcludeClientMACList)    
                                {    
                                        $cnt++    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "     MAC Address"; Value = $MAC; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $MAC; }) > $Null    
                                        }    
                                }    
                        }    
     
                        $ScriptInformation.Add(@{Data = "Connection to the following Gateway IPs"; Value = $RAS2FASettings.ExcludeClientGWIPs.ToString(); }) > $Null    
                        If($RAS2FASettings.ExcludeClientGWIPs)    
                        {    
                                $cnt = -1    
                                ForEach($Server in $RAS2FASettings.ExcludeClientGWIPList)    
                                {    
                                        $cnt++    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "     Server Name"; Value = $Server; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Server; }) > $Null    
                                        }                                                   }
                                }                                           }
                        }                                   }
 
                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 300;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""    
                }    
 
                $ScriptInformation = New-Object System.Collections.ArrayList <>                                 $ScriptInformation = New-Object System.Collections.ArrayList
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RAS2FASettings.ReplicateSettings.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateFileExtensionSettings.ToString(); }) > $Null
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 175;                                   $Table.Columns.Item(2).Width = 100;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
        }    
        If($Text)    
        {    
                Line 2 "Provider settings"                                   WriteWordLine 3 0 "License"
                Line 3 "Provider: " $RAS2FASettingsProvider                                   $ScriptInformation = New-Object System.Collections.ArrayList
                If($RAS2FASettingsProvider -ne "None")    
                {    
                        Line 3 "Settings"    
                            
                        If($RAS2FASettings.Provider -eq "AzureRadius")    
                        {    
                                Line 4 "Connection"    
                                Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.TypeName    
                                Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Server    
                                Line 5 "Secondary server`t`t`t: " $RAS2FASettings.AzureRadiusSettings.BackupServer    
                                If($RAS2FASettings.AzureRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"    
                                }    
                                Else    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"    
                                }    
                                Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Port    
                                Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Timeout    
                                Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Retries    
                                Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.AzureRadiusSettings.PasswordEncoding    
                                Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.AzureRadiusSettings.UsernameOnly.ToString()                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $PubItem.InheritLicenseDefaultSettings.ToString(); }) > $Null
                                Line 5 "Forward the first password to "    
                                Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.AzureRadiusSettings.ForwardFirstPwdToAD.ToString()    
                                Line 4 "Attributes"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "Attribute $cnt"    
                                        Line 6 "Name  : $($Item.Name)"    
                                        Line 6 "Vendor: $($Item.Vendor)"    
                                        Line 6 "Type  : $($Item.AttributeType)"    
                                        Line 6 "Value : $($Item.Value)"    
                                        Line 5 "" #blank separator line    
                                }    
                                Line 4 "Automation"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "" "Automation $cnt"    
                                        Line 6 "Enabled : $($Item.Enabled.ToString())"    
                                        Line 6 "Title   : $($Item.Title)"    
                                        Line 6 "Command : $($Item.Command)"    
                                        Line 6 "Image   : $($Item.Image)"    
                                        Line 6 "Autosend: $($Item.AutoSend.ToString())"    
                                        Line 5 "" "" #blank separator line    
                                }    
                                Line 0 ""    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "DuoRadius")    
                        {    
                                Line 4 "Connection"    
                                Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.TypeName    
                                Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Server    
                                Line 5 "Secondary server`t`t`t: " $RAS2FASettings.DuoRadiusSettings.BackupServer    
                                If($RAS2FASettings.DuoRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"    
                                }    
                                Else    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"    
                                }    
                                Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Port    
                                Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Timeout    
                                Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Retries    
                                Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.DuoRadiusSettings.PasswordEncoding    
                                Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.DuoRadiusSettings.UsernameOnly.ToString()    
                                Line 5 "Forward the first password to "    
                                Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.DuoRadiusSettings.ForwardFirstPwdToAD.ToString()    
                                Line 4 "Attributes"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AttributeInfoList)                                   If($PubItem.InheritLicenseDefaultSettings)
 
                                        $cnt++ <>  
                                        Line 5 "Attribute $cnt"    
                                        Line 6 "Name  : $($Item.Name)"    
                                        Line 6 "Vendor: $($Item.Vendor)"    
                                        Line 6 "Type  : $($Item.AttributeType)"    
                                        Line 6 "Value : $($Item.Value)"    
                                        Line 5 "" #blank separator line    
                                }    
                                Line 4 "Automation"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AutomationInfoList)                                           $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $DefaultDisableSessionSharing ; }) > $Null
                                {                                           If($DefaultOneInstancePerUser)
                                        $cnt++    
                                        Line 5 "" "Automation $cnt"    
                                        Line 6 "Enabled : $($Item.Enabled.ToString())"    
                                        Line 6 "Title   : $($Item.Title)"    
                                        Line 6 "Command : $($Item.Command)"    
                                        Line 6 "Image   : $($Item.Image)"    
                                        Line 6 "Autosend: $($Item.AutoSend.ToString())"    
                                        Line 5 "" "" #blank separator line    
                                }    
                                Line 0 ""    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "FortiRadius")    
                        {                                           {
                                Line 4 "Connection"                                                   $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null
                                Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.TypeName    
                                Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Server    
                                Line 5 "Secondary server`t`t`t: " $RAS2FASettings.FortiRadiusSettings.BackupServer    
                                If($RAS2FASettings.FortiRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"    
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"    
                                }    
                                Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Port    
                                Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Timeout    
                                Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Retries    
                                Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.FortiRadiusSettings.PasswordEncoding    
                                Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.FortiRadiusSettings.UsernameOnly.ToString()    
                                Line 5 "Forward the first password to "    
                                Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.FortiRadiusSettings.ForwardFirstPwdToAD.ToString()    
                                Line 4 "Attributes"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "Attribute $cnt"    
                                        Line 6 "Name  : $($Item.Name)"    
                                        Line 6 "Vendor: $($Item.Vendor)"    
                                        Line 6 "Type  : $($Item.AttributeType)"    
                                        Line 6 "Value : $($Item.Value)"    
                                        Line 5 "" #blank separator line    
                                }    
                                Line 4 "Automation"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "" "Automation $cnt"    
                                        Line 6 "Enabled : $($Item.Enabled.ToString())"    
                                        Line 6 "Title   : $($Item.Title)"    
                                        Line 6 "Command : $($Item.Command)"    
                                        Line 6 "Image   : $($Item.Image)"    
                                        Line 6 "Autosend: $($Item.AutoSend.ToString())"    
                                        Line 5 "" "" #blank separator line    
                                }    
                                Line 0 ""    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "TekRadius")    
                        {    
                                Line 4 "Connection"    
                                Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.TypeName    
                                Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Server    
                                Line 5 "Secondary server`t`t`t: " $RAS2FASettings.TekRadiusSettings.BackupServer    
                                If($RAS2FASettings.TekRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"    
                                }    
                                Else    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"    
                                }    
                                Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Port    
                                Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Timeout    
                                Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Retries    
                                Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.TekRadiusSettings.PasswordEncoding    
                                Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.TekRadiusSettings.UsernameOnly.ToString()    
                                Line 5 "Forward the first password to "    
                                Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.TekRadiusSettings.ForwardFirstPwdToAD.ToString()    
                                Line 4 "Attributes"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "Attribute $cnt"    
                                        Line 6 "Name  : $($Item.Name)"    
                                        Line 6 "Vendor: $($Item.Vendor)"    
                                        Line 6 "Type  : $($Item.AttributeType)"    
                                        Line 6 "Value : $($Item.Value)"    
                                        Line 5 "" #blank separator line    
                                }    
                                Line 4 "Automation"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "" "Automation $cnt"    
                                        Line 6 "Enabled : $($Item.Enabled.ToString())"    
                                        Line 6 "Title   : $($Item.Title)"    
                                        Line 6 "Command : $($Item.Command)"    
                                        Line 6 "Image   : $($Item.Image)"    
                                        Line 6 "Autosend: $($Item.AutoSend.ToString())"    
                                        Line 5 "" "" #blank separator line    
                                }    
                                Line 0 ""    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "Radius")    
                        {    
                                Line 4 "Connection"    
                                Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.RadiusSettings.TypeName    
                                Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.RadiusSettings.Server    
                                Line 5 "Secondary server`t`t`t: " $RAS2FASettings.RadiusSettings.BackupServer    
                                If($RAS2FASettings.RadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"    
                                }    
                                Else    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"    
                                }    
                                Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.RadiusSettings.Port    
                                Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.RadiusSettings.Timeout    
                                Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.RadiusSettings.Retries    
                                Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.RadiusSettings.PasswordEncoding    
                                Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.RadiusSettings.UsernameOnly.ToString()    
                                Line 5 "Forward the first password to "    
                                Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.RadiusSettings.ForwardFirstPwdToAD.ToString()    
                                Line 4 "Attributes"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "Attribute $cnt"    
                                        Line 6 "Name  : $($Item.Name)"    
                                        Line 6 "Vendor: $($Item.Vendor)"    
                                        Line 6 "Type  : $($Item.AttributeType)"    
                                        Line 6 "Value : $($Item.Value)"    
                                        Line 5 "" #blank separator line    
                                }    
                                Line 4 "Automation"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "" "Automation $cnt"    
                                        Line 6 "Enabled : $($Item.Enabled.ToString())"    
                                        Line 6 "Title   : $($Item.Title)"    
                                        Line 6 "Command : $($Item.Command)"    
                                        Line 6 "Image   : $($Item.Image)"    
                                        Line 6 "Autosend: $($Item.AutoSend.ToString())"    
                                        Line 5 "" "" #blank separator line    
                                }    
                                Line 0 ""    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "Deepnet")    
                        {    
                                Line 4 "Connection"    
                                Line 5 "Type`t`t: " $RAS2FASettings.DeepnetSettings.DeepnetType    
                                Line 5 "Server`t`t: " $RAS2FASettings.DeepnetSettings.Server    
                                Line 5 "Port`t`t: " $RAS2FASettings.DeepnetSettings.Port.ToString()    
                                Line 5 "Enable SSL`t: " $RAS2FASettings.DeepnetSettings.SSL.ToString()    
                                Line 5 "Agent`t`t: " $RAS2FASettings.DeepnetSettings.DeepnetAgent    
                                Line 4 "Application"    
                                Line 5 "          Application`t: " $RAS2FASettings.DeepnetSettings.App    
                                Line 5 "          Domain`t: " $RAS2FASettings.DeepnetSettings.DefaultDomain    
                                Line 4 "Authentication"    
                                Line 5 "          Mode`t`t: " $DeepNetAuthMode    
                                Line 5 "          Token Type`t: " $RAS2FASettings.DeepnetSettings.TokenType.ToString()    
                                Line 5 "          Allow Channels: " "Email: $($RAS2FASettings.DeepnetSettings.ActivateEmail.ToString())"    
                                Line 5 "                          " "SMS: $($RAS2FASettings.DeepnetSettings.ActivateSMS.ToString())"    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "SafeNet")    
                        {    
                                Switch($RAS2FASettings.SafeNetSettings.AuthMode)    
                                {    
                                        "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}    
                                        "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}                                                   $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null
                                        "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}    
                                        Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RAS2FASettings.SafeNetSettings.AuthMode)"; Break}    
                                }                                           }
     
                                Line 4 "Connection"    
                                Line 5 "OTP Service URL : " $RAS2FASettings.SafeNetSettings.DeepnetType    
                                Line 4 "Authentication"    
                                Line 5 "Mode`t`t`t: " $SafeNetAuthMode    
                                Line 5 "TMS Web API URL`t`t: " $RAS2FASettings.SafeNetSettings.TMSWebApiURL    
                                Line 5 "User Repository`t`t: " $RAS2FASettings.SafeNetSettings.UserRepository    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "GAuthTOTP")    
                        {    
                                Switch($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)    
                                {    
                                        "Allow"                 {$GAuthAllow = "Allow"; Break}    
                                        "AllowUntil"    {$GAuthAllow = "Allow until"; Break}    
                                        "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}    
                                        Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)"; Break}                                           $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $DefaultConCurrentLicenses; }) > $Null
                                }                                           $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $DefaultLicenseLimitNotify; }) > $Null
                                    
                                Switch($RAS2FASettings.GAuthTOTPSettings.Tolerance)    
                                {    
                                        0               {$TOTPTolerance = "None"; Break}    
                                        30              {$TOTPTolerance = "+/- 30 seconds"; Break}    
                                        60              {$TOTPTolerance = "+/- 60 seconds"; Break}    
                                        90              {$TOTPTolerance = "+/- 90 seconds"; Break}    
                                        120             {$TOTPTolerance = "+/- 120 seconds"; Break}    
                                        Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}    
 
                                 +-  
                                Line 4 "Type Name: " $RAS2FASettings.GAuthTOTPSettings.Type    
                                Line 4 "User Enrollment"    
                                Line 5 $GAuthAllow    
                                If($GAuthAllow -eq "Allow until")    
                                {    
                                        $GAuthFullDate = $RAS2FASettings.GAuthTOTPSettings.UntilDateTime    
                                        $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()    
                                        $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()    
                                        Line 6 "Date: " $GAuthDate    
                                        Line 6 "Time: " $GAuthTime    
                                }    
                                Line 4 "Authentication"    
                                Line 5 "TOTP tolerence: " $TOTPTolerance    
                        }    
     
                        If($RAS2FASettings.RestrictionMode -eq "Exclusion")    
                        {    
                                Line 3 "Enable MFA for all users except"    
                        }    
                        Else    
                        {    
                                Line 3 "Disable MFA for all users except"    
                        }    
                        Line 0 ""    
     
                        Line 2 "Restriction"    
                        Line 3 "User or group list`t`t`t: " $RAS2FASettings.ExcludeUserGroup.ToString()    
                        If($RAS2FASettings.ExcludeUserGroup)    
                        {    
                                If($RAS2FASettings.ExcludeUserGroupList.Count -gt 0)    
                                {    
                                        ForEach($Item in $RAS2FASettings.ExcludeUserGroupList)    
                                        {    
                                                Line 8 "  " "User: $($Item.Account)"    
                                                Line 8 "  " "Type: $($Item.Type)"    
                                                Line 8 "  "    
                                        }    
                                }    
                        }    
                                    
                        Line 3 "Client IP list`t`t`t`t: " $RAS2FASettings.ExcludeClientIPs.ToString()    
                        If($RAS2FASettings.ExcludeClientIPs)    
                        {    
                                If($RAS2FASettings.ExcludeClientIPList.Count -gt 0)    
                                {    
                                        $cnt     = -1    
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)    
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)    
     
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPList)    
                                        {    
                                                $cnt++    
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 6 "IPv4 Addresses`t: " $tmp    
                                                }    
                                                Else    
                                                {    
                                                        Line 8 "  " $tmp    
                                                }    
                                        }    
                                }    
                                    
                                If($RAS2FASettings.ExcludeClientIPv6List.Count -gt 0)    
                                {    
                                        $cnt     = -1    
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)    
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)    
     
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPv6List)    
                                        {    
                                                $cnt++    
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 6 "IPv6 Addresses`t: " $tmp    
                                                }    
                                                Else    
                                                {    
                                                        Line 8 "  " $tmp    
                                                }    
                                        }    
                                }    
                        }    
                        Line 3 "Client MAC list`t`t`t`t: " $RAS2FASettings.ExcludeClientMAC.ToString()    
                        If($RAS2FASettings.ExcludeClientMAC)    
                        {    
                                $cnt = -1    
                                ForEach($MAC in $RAS2FASettings.ExcludeClientMACList)    
                                {    
                                        $cnt++    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                Line 6 "MAC Address`t: " $MAC    
                                        }    
                                        Else    
                                        {    
                                                Line 8 "  " $MAC    
                                        }    
                                }    
                        }    
                        Line 3 "Connection to the following Gateway IPs`t: " $RAS2FASettings.ExcludeClientGWIPs.ToString()    
                        If($RAS2FASettings.ExcludeClientGWIPs)    
                        {    
                                $cnt = -1    
                                ForEach($Server in $RAS2FASettings.ExcludeClientGWIPList)    
                                {    
                                        $cnt++    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                Line 6 "Server Name`t: " $Server    
                                        }    
                                        Else    
                                        {    
                                                Line 8 "  " $Server    
                                        }    
                                }    
                        }    
                }    
                Line 0 ""    
                Line 2 "Settings are replicated to all Sites`t`t: " $RAS2FASettings.ReplicateSettings.ToString()    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @("Provider",($Script:htmlsb),$RAS2FASettingsProvider,$htmlwhite)    
                If($RAS2FASettingsProvider -ne "None")    
                {    
                        If($RAS2FASettings.Provider -eq "AzureRadius")    
                        {    
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.TypeName,$htmlwhite))    
                                $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Server,$htmlwhite))    
                                $rowdata += @(,("          Secondary server",($Script:htmlsb), $RAS2FASettings.AzureRadiusSettings.BackupServer,$htmlwhite))    
                                If($RAS2FASettings.AzureRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))    
                                }    
 
                                        $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite)) <>  
                                }    
                                $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Port,$htmlwhite))    
                                $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Timeout,$htmlwhite))    
                                $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Retries,$htmlwhite))    
                                $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.UsernameOnly.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))    
                                $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                                $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AutomationInfoList)                                           $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $SessionSharing; }) > $Null
                                {                                           If($PubItem.OneInstancePerUser)
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "DuoRadius")    
                        {                                           {
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.TypeName,$htmlwhite))    
                                $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Server,$htmlwhite))    
                                $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.DuoRadiusSettings.BackupServer,$htmlwhite))    
                                If($RAS2FASettings.DuoRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))    
                                }    
                                $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Port,$htmlwhite))    
                                $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Timeout,$htmlwhite))    
                                $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Retries,$htmlwhite))    
                                $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.UsernameOnly.ToString(),$htmlwhite))                                                   $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null
                                $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))    
                                $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }                                           }
                                $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "FortiRadius")    
                        {    
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.TypeName,$htmlwhite))    
                                $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Server,$htmlwhite))    
                                $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.FortiRadiusSettings.BackupServer,$htmlwhite))    
                                If($RAS2FASettings.FortiRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))    
                                }    
                                Else                                           Else
                                {                                           {
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))    
                                }    
                                $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Port,$htmlwhite))    
                                $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Timeout,$htmlwhite))    
                                $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Retries,$htmlwhite))    
                                $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.UsernameOnly.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))    
                                $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                                $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "TekRadius")    
                        {    
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.TypeName,$htmlwhite))    
                                $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Server,$htmlwhite))    
                                $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.TekRadiusSettings.BackupServer,$htmlwhite))    
                                If($RAS2FASettings.TekRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))    
                                }    
                                $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Port,$htmlwhite))    
                                $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Timeout,$htmlwhite))    
                                $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Retries,$htmlwhite))    
                                $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.UsernameOnly.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))    
                                $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                                $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "Radius")    
                        {    
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.RadiusSettings.TypeName,$htmlwhite))    
                                $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Server,$htmlwhite))    
                                $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.RadiusSettings.BackupServer,$htmlwhite))    
                                If($RAS2FASettings.RadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))    
                                }    
                                $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Port,$htmlwhite))    
                                $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Timeout,$htmlwhite))    
                                $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Retries,$htmlwhite))    
                                $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.RadiusSettings.PasswordEncoding.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.RadiusSettings.UsernameOnly.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.RadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))    
                                $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                                $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "Deepnet")    
                        {    
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,( "          Type",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.DeepnetType,$htmlwhite))    
                                $rowdata += @(,( "          Server",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.Server,$htmlwhite))    
                                $rowdata += @(,( "          Port",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.Port.ToString(),$htmlwhite))    
                                $rowdata += @(,( "          Enable SSL",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.SSL.ToString(),$htmlwhite))    
                                $rowdata += @(,( "          Agent",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.DeepnetAgent,$htmlwhite))    
                                $rowdata += @(,( "     Application",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,( "          Application",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.App,$htmlwhite))    
                                $rowdata += @(,( "          Domain",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.DefaultDomain,$htmlwhite))    
                                $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,( "          Mode",($Script:htmlsb), $DeepNetAuthMode,$htmlwhite))    
                                $rowdata += @(,( "          Token Type",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.TokenType.ToString(),$htmlwhite))    
                                $rowdata += @(,( "          Allow Channels",($Script:htmlsb), "Email: $($RAS2FASettings.DeepnetSettings.ActivateEmail.ToString())",$htmlwhite))    
                                $rowdata += @(,( "                        ",($Script:htmlsb), "SMS: $($RAS2FASettings.DeepnetSettings.ActivateSMS.ToString())",$htmlwhite))    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "SafeNet")    
                        {    
                                Switch($RAS2FASettings.SafeNetSettings.AuthMode)    
                                {    
                                        "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}    
                                        "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}                                                   $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null
                                        "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}    
                                        Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RAS2FASettings.SafeNetSettings.AuthMode)"; Break}    
                                }                                           }
     
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,( "          OTP Service URL",($Script:htmlsb),$RAS2FASettings.SafeNetSettings.OTPServiceURL,$htmlwhite))    
                                $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,( "          Mode",($Script:htmlsb), $SafeNetAuthMode,$htmlwhite))    
                                $rowdata += @(,( "          TMS Web API URL",($Script:htmlsb), $RAS2FASettings.SafeNetSettings.TMSWebApiURL,$htmlwhite))    
                                $rowdata += @(,( "          User Repository",($Script:htmlsb), $RAS2FASettings.SafeNetSettings.UserRepository,$htmlwhite))    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "GAuthTOTP")    
                        {    
                                Switch($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)    
                                {    
                                        "Allow"                 {$GAuthAllow = "Allow"; Break}    
                                        "AllowUntil"    {$GAuthAllow = "Allow until"; Break}    
                                        "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}    
                                        Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)"; Break}                                           $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $ConCurrentLicenses; }) > $Null
                                }                                           $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $LicenseLimitNotify; }) > $Null
                                    
                                Switch($RAS2FASettings.GAuthTOTPSettings.Tolerance)    
                                {    
                                        0               {$TOTPTolerance = "None"; Break}    
                                        30              {$TOTPTolerance = "+/- 30 seconds"; Break}    
                                        60              {$TOTPTolerance = "+/- 60 seconds"; Break}    
                                        90              {$TOTPTolerance = "+/- 90 seconds"; Break}    
                                        120             {$TOTPTolerance = "+/- 120 seconds"; Break}    
                                        Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}    
 
                                 <>  
                                $rowdata += @(,( "     Type Name",($Script:htmlsb),$RAS2FASettings.GAuthTOTPSettings.Type,$htmlwhite))    
                                $rowdata += @(,( "     User Enrollment",($Script:htmlsb),"",$htmlwhite))    
                                If($GAuthAllow -eq "Allow until")    
                                {    
                                        $GAuthFullDate = $RAS2FASettings.GAuthTOTPSettings.UntilDateTime                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                                        $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()                                   -Columns Data,Value `
                                        $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()    
                                        $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"Date: $GAuthDate",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb),"Time: $GAuthTime",$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"",$htmlwhite))    
                                }    
                                $rowdata += @(,( "     Authentication",($Script:htmlsb), "",$htmlwhite))    
                                $rowdata += @(,( "          TOTP tolerence",($Script:htmlsb), $TOTPTolerance,$htmlwhite))    
                        }    
                                    -List `
                        If($RAS2FASettings.RestrictionMode -eq "Exclusion")                                   -Format $wdTableGrid `
                        {                                   -AutoFit $wdAutoFitFixed;
                                $rowdata += @(,("Enable MFA for all users except",($Script:htmlsb),"",$htmlwhite))    
                        }    
                        Else                                   SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
                        {    
                                $rowdata += @(,("Disable MFA for all users except",($Script:htmlsb),"",$htmlwhite))                                   $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
                        }    
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        $msg = "Provider settings" <>                                 FindWordDocumentEnd
                        $columnWidths = @("300","175")                                   $Table = $Null
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""                                   WriteWordLine 0 0 ""
 
                        $rowdata = @() <>  
                        $columnHeaders = @("User or group list",($Script:htmlsb),$RAS2FASettings.ExcludeUserGroup.ToString(),$htmlwhite)    
                        If($RAS2FASettings.ExcludeUserGroup)    
                        {    
                                If($RAS2FASettings.ExcludeUserGroupList.Count -gt 0)    
                                {    
                                        ForEach($Item in $RAS2FASettings.ExcludeUserGroupList)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"User: $($Item.Account)",$htmlwhite))    
                                                $rowdata += @(,("",($Script:htmlsb),"Type: $($Item.Type)",$htmlwhite))    
                                                $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
                        }    
                            
                        $rowdata += @(,("Client IP list",($Script:htmlsb),$RAS2FASettings.ExcludeClientIPs.ToString(),$htmlwhite))    
                        If($RAS2FASettings.ExcludeClientIPs)    
                        {    
                                If($RAS2FASettings.ExcludeClientIPList.Count -gt 0)    
                                {    
                                        $cnt     = -1    
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)    
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)                                   $ScriptInformation = New-Object System.Collections.ArrayList
     
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPList)                                   If($PubItem.InheritLicenseDefaultSettings)
                                        {    
                                                $cnt++    
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("     IPv4 Addresses",($Script:htmlsb),$tmp,$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                    
                                If($RAS2FASettings.ExcludeClientIPv6List.Count -gt 0)    
 
                                        $cnt     = -1 <>  
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)    
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)    
     
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPv6List)    
                                        {    
                                                $cnt++    
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("     IPv6 Addresses",($Script:htmlsb),$tmp,$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))    
                                                }    
                                        }    
                                }    
                        }    
                        $rowdata += @(,("Client MAC list",($Script:htmlsb),$RAS2FASettings.ExcludeClientMAC.ToString(),$htmlwhite))    
                        If($RAS2FASettings.ExcludeClientMAC)    
                        {    
                                $cnt = -1    
                                ForEach($MAC in $RAS2FASettings.ExcludeClientMACList)    
                                {    
                                        $cnt++    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("     MAC Address",($Script:htmlsb),$MAC,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$MAC,$htmlwhite))    
                                        }    
                                }    
                        }    
                        $rowdata += @(,("Connection to the following Gateway IPs",($Script:htmlsb),$RAS2FASettings.ExcludeClientGWIPs.ToString(),$htmlwhite))                                           $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $DefaultReplicateLicenseSettings.ToString(); }) > $Null
                        If($RAS2FASettings.ExcludeClientGWIPs)    
                        {    
                                $cnt = -1    
                                ForEach($Server in $RAS2FASettings.ExcludeClientGWIPList)    
                                {    
                                        $cnt++    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("     Server Name",($Script:htmlsb),$Server,$htmlwhite))    
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $rowdata += @(,("",($Script:htmlsb),$Server,$htmlwhite))    
                                        }    
                                }    
                        }    
                }    
                $msg = "Restriction"    
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
     
                $rowdata = @()    
                $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$RAS2FASettings.ReplicateSettings.ToString(),$htmlwhite)                                           $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateLicenseSettings.ToString(); }) > $Null
     
                $msg = ""    
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }                                   }
}    
 
Function OutputRASAllowedDevicesSetting <>  
{    
        Param([object] $RASAllowedDevices)    
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Allowed devices"    
            
        Switch ($RASAllowedDevices.AllowClientMode)    
        {    
                "AllowAllClientsConnectToSystem"                            
                        {$RASAllowedDevicesAllowClientMode = "Allow all clients to connect to the system"; Break}    
                "AllowSelectedClientsConnectToSystem"               
                        {$RASAllowedDevicesAllowClientMode = "Allow only the selected clients to connect to the system"; Break}    
                "AllowSelectedClientsListPublishedItems"            
                        {$RASAllowedDevicesAllowClientMode = "Allow only the selected clients to list the published items"; Break}    
                Default                                                                             
                        {$RASAllowedDevicesAllowClientMode = "Unable to determine Allow Client Mode: $($RASAllowedDevices.AllowClientMode)"; Break}    
        }    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Allowed devices"    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Secure Access"; Value = ""; }) > $Null    
                $ScriptInformation.Add(@{Data = "     Allow only clients with the latest security patches"; Value = $RASAllowedDevices.AllowClientWithSecurityPatchesOnly.ToString(); }) > $Null    
                $ScriptInformation.Add(@{Data = "Device Access"; Value = ""; }) > $Null    
                $ScriptInformation.Add(@{Data = "     Mode"; Value = $RASAllowedDevicesAllowClientMode; }) > $Null    
     
                $Table = AddWordTable -Hashtable $ScriptInformation `                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 175;                                   $Table.Columns.Item(2).Width = 100;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
 
                $AllowedDevicesWordTable = @() <>  
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientWindows    
                        ClientName         = "Windows client"                                   WriteWordLine 3 0 "Display"
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildWindows    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientMAC    
                        ClientName         = "macOS client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildMAC    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientLinux    
                        ClientName         = "Linux client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildLinux    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientIOS    
                        ClientName         = "iOS client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildIOS    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientAndroid    
                        ClientName         = "Android client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildAndroid    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientHTML5    
                        ClientName         = "HTML5 client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildHTML5    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientChromeApp    
                        ClientName         = "Chrome client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildChromeApp    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientWebPortal                                   $ScriptInformation = New-Object System.Collections.ArrayList
                        ClientName         = "RAS Web Portal"                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $PubItem.InheritDisplayDefaultSettings.ToString(); }) > $Null
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildWebPortal    
                }    
                                                  If($PubItem.InheritDisplayDefaultSettings)
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientWyse    
                        ClientName         = "Wyse client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildWyse    
                }                                   {
                                                          $ScriptInformation.Add(@{Data = "Wait until all RAS Universal Printers are redirected before showing the application"; Value = $DefaultWaitForPrinters; }) > $Null
                $AllowedDevicesWordTable += @{                                           $ScriptInformation.Add(@{Data = "Maximum time to wait is"; Value = "$($DefaultWaitForPrintersTimeout) seconds"; }) > $Null
                        ClientStatus       = $RASAllowedDevices.AllowClientJava                                           $ScriptInformation.Add(@{Data = "Color Depth"; Value = $DefaultColorDepth; }) > $Null
                        ClientName         = "Java client"                                           $ScriptInformation.Add(@{Data = "Start the application as maximized when using mobile clients"; Value = $DefaultStartMaximized; }) > $Null
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildJava    
                }                                   }
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientWinPhone    
                        ClientName         = "Windows Phone client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildWinPhone    
                }                                   Else
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientBlackberry    
                        ClientName         = "Blackberry client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildBlackberry    
                }                                   {
                                                          $ScriptInformation.Add(@{Data = "Wait until all RAS Universal Printers are redirected before showing the application"; Value = $PubItem.WaitForPrinters.ToString(); }) > $Null
                $AllowedDevicesWordTable += @{                                           $ScriptInformation.Add(@{Data = "Maximum time to wait is"; Value = "$($PubItem.WaitForPrintersTimeout.ToString()) seconds"; }) > $Null
                        ClientStatus       = $RASAllowedDevices.AllowClient2XOS                                           $ScriptInformation.Add(@{Data = "Color Depth"; Value = $ColorDepth; }) > $Null
                        ClientName         = "2X OS client"                                           $ScriptInformation.Add(@{Data = "Start the application as maximized when using mobile clients"; Value = $PubItem.StartMaximized.ToString(); }) > $Null
                        ClientMinimumBuild = $RASAllowedDevices.MinBuild2XOS    
                }                                   }
 
                If($AllowedDevicesWordTable.Count -gt 0) <>  
                {    
                        $Table = AddWordTable -Hashtable $AllowedDevicesWordTable `                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns ClientStatus, ClientName, ClientMinimumBuild `                                   -Columns Data,Value `
                        -Headers "Enabled", "Clients", "Minimum build" `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 50; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 125;    
                        $Table.Columns.Item(3).Width = 100;                                   $Table.Columns.Item(2).Width = 300;
                            
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                    
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    If($PubItem.InheritDisplayDefaultSettings)
                                    {
                                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $DefaultReplicateDisplaySettings.ToString(); }) > $Null
                }                                   }
                                    Else
                                    {
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASAllowedDevices.ReplicateSettings.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateDisplaySettings.ToString(); }) > $Null
                                    }
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 100;                                   $Table.Columns.Item(2).Width = 100;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
        }                           }
        If($Text)                           If($Text)
        {                           {
                Line 0 "Allowed devices"    
                Line 1 "Secure Access"    
                Line 2 "Allow only clients with the latest security patches: " $RASAllowedDevices.AllowClientWithSecurityPatchesOnly.ToString()    
                Line 1 "Device Access"    
                Line 2 "Mode: " $RASAllowedDevicesAllowClientMode    
                Line 0 ""                                   Line 2 "Information"
                Line 2 "Enabled Clients              Minimum build"                                   Line 3 "Windows Virtual Desktop`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
                Line 2 "=========================================="                                   Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description
                #               1234567S12345678901234567890S1234                                   Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod
                #       False   WIndows Phone client 9999                                   Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWindows, "Windows client", $RASAllowedDevices.MinBuildWindows)                                   Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientMAC, "macOS client", $RASAllowedDevices.MinBuildMAC)                                   Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientLinux, "Linux client", $RASAllowedDevices.MinBuildLinux)                                   Line 3 "Target`t`t`t`t`t`t`t: " $PubItem.Target
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientIOS, "iOS client", $RASAllowedDevices.MinBuildIOS)                                   Line 3 "Start In`t`t`t`t`t`t: " $PubItem.StartIn
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientAndroid, "Android client", $RASAllowedDevices.MinBuildAndroid)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientHTML5, "HTML5 client", $RASAllowedDevices.MinBuildHTML5)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientChromeApp, "Chrome client", $RASAllowedDevices.MinBuildChromeApp)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWebPortal, "RAS Web Portal", $RASAllowedDevices.MinBuildWebPortal)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWyse, "Wyse client", $RASAllowedDevices.MinBuildWyse)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientJava, "Java client", $RASAllowedDevices.MinBuildJava)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWinPhone, "Windows Phone client", $RASAllowedDevices.MinBuildWinPhone)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientBlackberry, "Blackberry client", $RASAllowedDevices.MinBuildBlackberry)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClient2XOS, "2X OS client", $RASAllowedDevices.MinBuild2XOS)    
                Line 0 ""    
                Line 2 "Settings are replicated to all Sites: " $RASAllowedDevices.ReplicateSettings.ToString()                                   Line 3 "Start automatically when user logs on`t`t`t: " $PubItem.StartOnLogon.ToString()
                                    
                                    If(![String]::IsNullOrEmpty($PubItem.Parameters))
                Line 0 ""                                   {
                                            Line 3 "Parameters`t`t`t`t`t`t: " $PubItem.Parameters
        }                                   }
        If($HTML)                                  
                                    If($PubItem.EnableFileExtensions)
        {                                   {
                WriteHTMLLine 2 0 "Allowed devices"                                           Line 3 "Associate the following file extensions"
                                            ForEach($Item in $PubItem.FileExtensions)
                $rowdata = @()    
                $columnHeaders = @("Allow only clients with the latest security patches",($Script:htmlsb),$RASAllowedDevices.AllowClientWithSecurityPatchesOnly.ToString(),$htmlwhite)    
                                            {
                $msg = "Secure Access"    
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""                                                   Line 10 $Item
     
                $rowdata = @()    
                $columnHeaders = @("Mode",($Script:htmlsb),$RASAllowedDevicesAllowClientMode,$htmlwhite)    
     
                $msg = "Device Access"    
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
     
                $rowdata = @()    
     
                $rowdata += @(,($RASAllowedDevices.AllowClientWindows,$htmlwhite,"Windows client",$htmlwhite,$RASAllowedDevices.MinBuildWindows,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientMAC,$htmlwhite,"macOS client",$htmlwhite,$RASAllowedDevices.MinBuildMAC,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientLinux,$htmlwhite,"Linux client",$htmlwhite,$RASAllowedDevices.MinBuildLinux,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientIOS,$htmlwhite,"iOS client",$htmlwhite,$RASAllowedDevices.MinBuildIOS,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientAndroid,$htmlwhite,"Android client",$htmlwhite,$RASAllowedDevices.MinBuildAndroid,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientHTML5,$htmlwhite,"HTML5 client",$htmlwhite,$RASAllowedDevices.MinBuildHTML5,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientChromeApp,$htmlwhite,"Chrome client",$htmlwhite,$RASAllowedDevices.MinBuildChromeApp,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientWebPortal,$htmlwhite,"RAS Web Portal",$htmlwhite,$RASAllowedDevices.MinBuildWebPortal,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientWyse,$htmlwhite,"Wyse client",$htmlwhite,$RASAllowedDevices.MinBuildWyse,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientJava,$htmlwhite,"Java client",$htmlwhite,$RASAllowedDevices.MinBuildJava,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientWinPhone,$htmlwhite,"Windows Phone client",$htmlwhite,$RASAllowedDevices.MinBuildWinPhone,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientBlackberry,$htmlwhite,"Blackberry client",$htmlwhite,$RASAllowedDevices.MinBuildBlackberry,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClient2XOS,$htmlwhite,"2X OS client",$htmlwhite,$RASAllowedDevices.MinBuild2XOS,$htmlwhite))    
                    
                $columnHeaders = @(    
                "Enabled",($Script:htmlsb),    
                "Clients",($Script:htmlsb),    
                "Minimum build",($Script:htmlsb))    
     
                $msg = ""    
                $columnWidths = @("54","125","100")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
     
                $rowdata = @()    
                $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$RASAllowedDevices.ReplicateSettings.ToString(),$htmlwhite)    
     
                $msg = ""    
                $columnWidths = @("183","100")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }                                           }
}                                   }
#endregion    
                                    
#region process policies                                   If($PubItem.InheritLicenseDefaultSettings)
Function ProcessPolicies    
{                                   {
        Write-Verbose "$(Get-Date -Format G): Processing Policies"                                           Line 3 "Allow users to start only 1 instance of this application: " $DefaultOneInstancePerUser.ToString()
                                            Line 3 "Concurrent licenses`t`t`t`t`t: " $DefaultConCurrentLicenses
                                            Line 3 "If limit is exceeded`t`t`t`t`t: " $DefaultLicenseLimitNotify
                                            Line 3 "Session Sharing`t`t`t`t`t`t: " $DefaultDisableSessionSharing 
                                          }
        OutputPoliciesSectionPage                                   Else
                                          {
        Write-Verbose "$(Get-Date -Format G): `tProcessing Policies Summary"                                           Line 3 "Allow users to start only 1 instance of this application: " $PubItem.OneInstancePerUser.ToString()
                                            Line 3 "Concurrent licenses`t`t`t`t`t: " $ConCurrentLicenses
                                            Line 3 "If limit is exceeded`t`t`t`t`t: " $LicenseLimitNotify
                                            Line 3 "Session Sharing`t`t`t`t`t`t: " $SessionSharing
                                          }
        $Policies = Get-RASClientPolicy -EA 0 4>$Null    
                                    Line 3 "Settings for Site $xSiteName"
                                          
        If(!($?))                                   If($PubItem.PublishFrom -eq "Server")
        {                                   {
                Write-Warning "    
                `n                                           $cnt = -1
                Unable to retrieve Policies information                                           ForEach($Item in $PubItem.PublishFromServer)
                "    
                If($MSWord -or $PDF)    
                {                                           {
                        WriteWordLine 0 0 "Unable to retrieve Policies information"    
                }                                                   $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                If($Text)                                                   If($cnt -eq 0)
                {                                                   {
                        Line 0 "Unable to retrieve Policies information"                                                           Line 3 "Published from`t`t`t`t`t`t: " ItemName
                }                                                   }
                If($HTML)                                                   Else
                {                                                   {
                        WriteHTMLLine 0 0 "Unable to retrieve Policies information"                                                           Line 10 $ItemName
                }                                                   }
        }                                           }
        ElseIf($? -and $null -eq $Policies)                                   }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
        {                                   {
                Write-Host "                                           $cnt = -1
                No Policies information was found                                           ForEach($Item in $PubItem.PublishFromGroup)
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {                                           {
                        WriteWordLine 0 0 "No Policies information was found"    
                }                                                   $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                If($Text)                                                   If($cnt -eq 0)
                {                                                   {
                        Line 0 "No Policies information was found"                                                           Line 3 "Published from`t`t`t`t`t`t: " ItemName
                }                                                   }
                If($HTML)                                                   Else
                {                                                   {
                        WriteHTMLLine 0 0 "No Policies information was found"                                                           Line 10 $ItemName
                }                                                   }
        }                                           }
                                    }
        Else                                   Else
        {                                   {
                OutputPoliciesSummary $Policies                                           Line 3 "Published from`t`t`t`t`t`t: " "All Servers in Site"
                OutputPoliciesDetails $Policies    
        }                                   }
 
} <>                                 If($PubItem.InheritShortcutDefaultSettings)
     
Function OutputPoliciesSectionPage    
{                                   {
        If($MSWord -or $PDF)                                           If($DefaultCreateShortcutOnDesktop -eq "True")
        {                                           {
                $Script:Selection.InsertNewPage()    
                WriteWordLine 1 0 "Policies"                                                   Line 3 "Create shortcut on desktop"
        }                                           }
        If($Text)                                           If($DefaultCreateShortcutInStartFolder -eq "True")
        {                                           {
                Line 0 "Policies"                                                   Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"
        }                                           }
        If($HTML)                                           If($DefaultCreateShortcutInStartUpFolder -eq "True")
        {                                           {
                WriteHTMLLine 1 0 "Policies"                                                   Line 3 "Create shortcut in Auto Start Folder"
        }                                           }
}                                   }
                                    Else
Function OutputPoliciesSummary    
{                                   {
        Param([object] $Policies)                                           If($PubItem.CreateShortcutOnDesktop)
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Policies Summary"    
            
        If($MSWord -or $PDF)    
        {                                           {
                WriteWordLine 2 0 "Policies"                                                   Line 3 "Create shortcut on desktop"
        }                                           }
        If($Text)                                           If($PubItem.CreateShortcutInStartFolder)
        {                                           {
                Line 1 "Policies"                                                   Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"
        }                                           }
        If($HTML)                                           If($PubItem.CreateShortcutInStartUpFolder)
        {                                           {
                WriteHTMLLine 2 0 "Policies"                                                   Line 3 "Create shortcut in Auto Start Folder"
        }                                           }
            
        ForEach($Policy in $Policies)    
        {    
                $ClientOptions   = $Policy.ClientPolicy.ClientOptions    
                $ControlSettings = $Policy.ClientPolicy.ControlSettings    
                $Redirection     = $Policy.ClientPolicy.Redirection    
                $Session         = $Policy.ClientPolicy.Session    
                $Categories      = @()    
                    
                If($Redirection.Enabled)    
                {    
                        $Categories += "Redirection"    
                }                                   }
                    
                If(                                       If($PubItem.UserFilterEnabled -or 
                        $ControlSettings.ControlSettingsConnections.Enabled -or     
                        $ControlSettings.Password.Enabled -or                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                        $ControlSettings.ImportExport.Enabled)                                      $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                {                                   {
                        $Categories += "Control settings"                                           Line 3 "Own Filters"
                }                                   }
                    
                If(     
                        $ClientOptions.Connection.Enabled -or     
                        $ClientOptions.Logging.Enabled -or     
                        $ClientOptions.PCKeyboard.Enabled -or                                    If($PubItem.UserFilterEnabled)
                        $ClientOptions.Update.Enabled -or     
                        $ClientOptions.SingleSignOn.Enabled -or     
                        $ClientOptions.Global.Enabled -or     
                        $ClientOptions.Language.Enabled -or     
                        $ClientOptions.Printing.Enabled -or     
                        $ClientOptions.WindowsClient.Enabled -or     
                        $ClientOptions.RemoteFxUsbRedirection.Enabled)    
                {                                   {
                        $Categories += "Client options"                                           Line 3 " User filtering is enabled"
                }    
                                                          
                If(     
                        $Session.PrimaryConnection.Enabled -or              
                        $Session.SecondaryConnections.Enabled -or     
                        $Session.Reconnection.Enabled -or     
                        $Session.ComputerName.Enabled -or     
                        $Session.ConnectionAdvancedSettings.Enabled -or     
                        $Session.WebAuthentication.Enabled -or     
                        $Session.MultiFactorAuthentication.Enabled -or     
                        $Session.SessionPreLaunch.Enabled -or     
                        $Session.LocalProxyAddress.Enabled -or     
                        $Session.Settings.Enabled -or     
                        $Session.MultiMonitor.Enabled -or     
                        $Session.PublishedApplications.Enabled -or          
                        $Session.DesktopOptions.Enabled -or     
                        $Session.Browser.Enabled -or     
                        $Session.Printing.Enabled -or     
                        $Session.Scanning.Enabled -or     
                        $Session.Audio.Enabled -or     
                        $Session.Keyboard.Enabled -or     
                        $Session.Clipboard.Enabled -or     
                        $Session.DiskDrives.Enabled -or     
                        $Session.Devices.Enabled -or     
                        $Session.Ports.Enabled -or     
                        $Session.SmartCards.Enabled -or     
                        $Session.WindowsTouchInput.Enabled -or     
                        $Session.FileTransfer.Enabled -or     
                        $Session.Performance.Enabled -or     
                        $Session.Compression.Enabled -or     
                        $Session.Network.Enabled -or     
                        $Session.AdvancedSettings.Enabled -or       
                        $Session.ServerAuthentication.Enabled                                                     ForEach($Item in $PubItem.AllowedUsers)
                )    
                {                                           {
                        $Categories += "Session"                                                   Line 10 "  " $Item.Account
                }                                           }
                                            Line 0 ""
                                    }
                If($MSWord -or $PDF)                                   If($PubItem.IPFilterEnabled)
                {                                   {
                        $ScriptInformation = New-Object System.Collections.ArrayList                                           Line 3 " IP filtering is enabled"
                        $ScriptInformation.Add(@{Data = "Name"; Value = $Policy.Name; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Enabled"; Value = $Policy.Enabled; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Version"; Value = $Policy.Version; }) > $Null    
                            
                        If($Categories.Count -eq 0)                                           If($PubItem.AllowedIP4s.Count -gt 0)
                        {                                           {
                                $ScriptInformation.Add(@{Data = "Category"; Value = ""; }) > $Null                                                   ForEach($item in $PubItem.AllowedIP4s)
                        }                                                   {
                        ElseIf($Categories.Count -eq 4)                                                           If($item.From -eq $item.To)
                        {                                                           {
                                $ScriptInformation.Add(@{Data = "Category"; Value = "All Categories"; }) > $Null                                                                   Line 10 "  " $item.From
                        }                                                           }
                        Else                                                           Else
                        {                                                           {
                                                                    Line 10 "  $($item.From) - $($item.To)"
                                $cnt=-1                                                           }
                                                    }
                                            }
                                    
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                ForEach($Category in $Categories)                                                   ForEach($item in $PubItem.AllowedIP6s)
                                {                                                   {
                                        $cnt++                                                           If($item.From -eq $item.To)
                                            
                                        If($cnt -eq 0)    
                                        {                                                           {
                                                $ScriptInformation.Add(@{Data = "Category"; Value = $Category; }) > $Null                                                                   Line 10 "  " $item.From
                                        }                                                           }
                                        Else                                                           Else
                                        {                                                           {
                                                $ScriptInformation.Add(@{Data = ""; Value = $Category; }) > $Null                                                                   Line 10 "  $($item.From) - $($item.To)"
                                        }                                                           }
                                }                                                   }
                        }                                           }
                            
                        $ScriptInformation.Add(@{Data = "Description"; Value = $Policy.Description; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Policy.AdminLastMod; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $Policy.TimeLastMod.ToString(); }) > $Null    
                        $ScriptInformation.Add(@{Data = "Created by"; Value = $Policy.AdminCreate; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Created on"; Value = $Policy.TimeCreate.ToString(); }) > $Null    
                        $ScriptInformation.Add(@{Data = "ID"; Value = $Policy.Id; }) > $Null    
     
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 125;    
                        $Table.Columns.Item(2).Width = 175;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""                                           Line 0 ""
                }                                   }
                If($Text)                                   If($PubItem.ClientFilterEnabled)
                {                                   {
                        Line 2 "Name`t`t`t: " $Policy.Name                                           Line 3 " Client filtering is enabled"
                        Line 2 "Enabled`t`t`t: " $Policy.Enabled    
                        Line 2 "Version`t`t`t: " $Policy.Version    
                                                                  
                        If($Categories.Count -eq 0)                                           ForEach($item in $PubItem.AllowedClients)
                        {                                           {
                                Line 2 "Category`t`t: " ""                                                   Line 10 "  " $Item
                        }                                           }
                                            Line 0 ""
                                    }
                        ElseIf($Categories.Count -eq 4)                                   If($PubItem.MACFilterEnabled)
                        {                                   {
                                Line 2 "Category`t`t: " "All Categories"                                           Line 3 " MAC filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    Line 10 "  " $Item
                        }                                           }
                                            Line 0 ""
                        Else                                   }
                                    If($PubItem.GatewayFilterEnabled)
                        {                                   {
                                $cnt=-1                                           Line 3 " Gateway filtering is enabled"
                                                                          
                                ForEach($Category in $Categories)                                           ForEach($item in $PubItem.AllowedGateways)
                                {                                           {
                                                    Line 10 "  " $Item
                                        $cnt++                                           }
                                            Line 0 ""
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            Line 3 " Client device operating system filtering is enabled"
 
                                        If($cnt -eq 0) <>                                         If($PubItem.AllowedOSes.Android)
 
                                                Line 2 "Category`t`t: " $Category <>                                                 Line 10Android"
 
                                        Else <>                                        
                                            If($PubItem.AllowedOSes.Chrome)
 
                                                Line 5 " $Category <>                                                 Line 10Chrome OS"
 
  <>                                         
                                            If($PubItem.AllowedOSes.iOS)
                                }                                           {
                                                    Line 10 "  iOS/iPadOS"
                        }                                           }
                                                                  
                        Line 2 "Description`t`t: " $Policy.Description                                           If($PubItem.AllowedOSes.Linux)
                        Line 2 "Last modification by`t: " $Policy.AdminLastMod                                           {
                        Line 2 "Modified on`t`t: " $Policy.TimeLastMod.ToString()    
                        Line 2 "Created by`t`t: " $Policy.AdminCreate    
                        Line 2 "Created on`t`t: " $Policy.TimeCreate.ToString()    
                        Line 2 "ID`t`t`t: " $Policy.Id    
                        Line 0 ""                                                   Line 10 "  Linux"
                }                                           }
                If($HTML)                                          
                                            If($PubItem.AllowedOSes.Mac)
                {                                           {
                        $rowdata = @()                                                   Line 10 "  macOS"
                        $columnHeaders = @("Name",($Script:htmlsb),$Policy.Name,$htmlwhite)                                           }
                        $rowdata += @(,("Enabled",($Script:htmlsb),$Policy.Enabled,$htmlwhite))    
                        $rowdata += @(,("Version",($Script:htmlsb),$Policy.Version,$htmlwhite))    
                                                                  
                        If($Categories.Count -eq 0)                                           If($PubItem.AllowedOSes.WebPortal)
                        {                                           {
                                $rowdata += @(,("Category",($Script:htmlsb),"",$htmlwhite))                                                   Line 10 "  RAS Web Portal"
                        }                                           }
                                            
                        ElseIf($Categories.Count -eq 4)                                           If($PubItem.AllowedOSes.Windows)
                        {                                           {
                                $rowdata += @(,("Category",($Script:htmlsb),"All Categories",$htmlwhite))                                                   Line 10 "  Windows"
                        }                                           }
                        Else                                          
                                            If($PubItem.AllowedOSes.Wyse)
                        {                                           {
                                                    Line 10 "  Wyse"
                                            }
                                            Line 0 ""
                                    }
     
                                $cnt=-1                                   $cnt =-1
                                    
                                ForEach($Category in $Categories)                                   ForEach($Site in $PubItem.PublishToSite)
 
  -+                                         $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
 
                                                $rowdata += @(,("Category",($Script:htmlsb),$Category,$htmlwhite)) <>                                                 Line 3 "Available in Site(s)`t`t`t`t`t: " $SiteName
 
                                                $rowdata += @(,("",($Script:htmlsb),$Category,$htmlwhite)) <>                                                 Line 10 $SiteName
 
  <>                                 Line 0 ""
     
                                    Line 2 "Sites"
                                    Line 3 "This published item will be available from the following Sites"
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            Line 10 $SiteName
                        }                                   }
                                    Line 0 ""
                            
                        $rowdata += @(,("Description",($Script:htmlsb),$Policy.Description,$htmlwhite))                                   Line 2 "Publish from"
                        $rowdata += @(,("Last modification by",($Script:htmlsb), $Policy.AdminLastMod,$htmlwhite))                                   Line 3 $PublishedFrom
                        $rowdata += @(,("Modified on",($Script:htmlsb), $Policy.TimeLastMod.ToString(),$htmlwhite))                                   If($PubItem.PublishFrom -eq "Server")
                        $rowdata += @(,("Created by",($Script:htmlsb), $Policy.AdminCreate,$htmlwhite))    
                        $rowdata += @(,("Created on",($Script:htmlsb), $Policy.TimeCreate.ToString(),$htmlwhite))    
                        $rowdata += @(,("ID",($Script:htmlsb),$Policy.Id,$htmlwhite))    
                                    {
                        $msg = ""                                           ForEach($Item in $PubItem.PublishFromServer)
                        $columnWidths = @("150","200")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }                                           {
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    Line 6 $ItemName
        }                                           }
}                                   }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
Function OutputPoliciesDetails    
{                                   {
        Param([object] $Policies)                                           ForEach($Item in $PubItem.PublishFromGroup)
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Policy Properties"    
            
        If($MSWord -or $PDF)    
        {                                           {
                WriteWordLine 2 0 "Policy Properties"                                                   $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    Line 5 $ItemName
        }                                           }
        If($Text)    
        {    
                Line 1 "Policy Properties"    
        }                                   }
                                    Line 0 ""
        If($HTML)    
                                    Line 2 "Application"
                                    Line 3 "Application"
                                    Line 4 "Name`t`t`t`t`t`t":  $PubItem.Name
                                    Line 4 "Description`t`t`t`t`t: " $PubItem.Description
                                    Line 4 "Run`t`t`t`t`t`t: " $WinType
                                    Line 4 "Target`t`t`t`t`t`t: " $PubItem.Target
                                    Line 4 "Start in`t`t`t`t`t: " $PubItem.StartIn
                                    Line 4 "Parameters`t`t`t`t`t: " $PubItem.Parameters
                                    Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()
                                    Line 4 "Exclude from session prelaunch`t`t`t: "; Value = $PubItem.ExcludePrelaunch.ToString()
                                    Line 0 ""
                                    
                                    OutputPubItemFilters $PubItem "Text"
                                    
                                    OutputPubItemShortcuts $PubItem "Text" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
     
                                    Line 2 "File extensions"
                                    Line 3 "Associate File Extensions`t`t`t`t: " $PubItem.EnableFileExtensions.ToString()
     
                                    If($PubItem.EnableFileExtensions)
        {                                   {
                WriteHTMLLine 2 0 "Policy Properties"    
        }                                           $cnt = -1
            
        ForEach($Policy in $Policies)                                           ForEach($Item in $PubItem.FileExtensions)
        {                                           {
                Write-Verbose "$(Get-Date -Format G): `t`t`tProcessing Policy $($Policy.Name)"    
                    
                $ClientOptions   = $Policy.ClientPolicy.ClientOptions    
                $ControlSettings = $Policy.ClientPolicy.ControlSettings    
                $Redirection     = $Policy.ClientPolicy.Redirection    
                $Session         = $Policy.ClientPolicy.Session    
                                                    $cnt++
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tPolicy"                                                   If($cnt -eq 0 )
                If($MSWord -or $PDF)    
                {                                                   {
                        WriteWordLine 3 0 "Policy $($Policy.Name)"                                                           Line 8 "Extension:`t" $Item
                        WriteWordLine 4 0 "Policy"    
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $ScriptInformation.Add(@{Data = "Name"; Value = $Policy.Name; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Description"; Value = $Policy.Description; }) > $Null    
                                                    }
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
                                                    Else
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 125;    
                        $Table.Columns.Item(2).Width = 175;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
     
                        WriteWordLine 4 0 "Apply policy to"    
                        [System.Collections.Hashtable[]] $NameWordTable = @();    
                            
                        ForEach($Item in $Policy.UsersGroups)    
                        {                                                   {
                                $NameTableRowHash = @{    
                                Name = $Item.Account;    
                                Type = $Item.Type;    
                                SID  = $Item.Sid;                                                           Line 10 $Item
                                }                                                   }
                                $NameWordTable += $NameTableRowHash;                                           }
                        }                                   }
                                    Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateFileExtensionSettings.ToString()
                                    Line 0 ""
 
                        If($NameWordTable.Count -gt 0) <>                                 Line 2 "License"
                                    Line 3 "Inherit default settings`t`t`t`t: " $PubItem.InheritLicenseDefaultSettings.ToString()
     
                                    If($PubItem.InheritLicenseDefaultSettings)
                        {                                   {
                                $Table = AddWordTable -Hashtable $NameWordTable `                                           Line 3 "Session Sharing`t`t`t`t`t`t: " $DefaultDisableSessionSharing
                                -Columns  Name,Type,SID `                                           Line 3 "Allow users to start only 1 instance of this application: " $DefaultOneInstancePerUser.ToString()
                                -Headers  "Name","Type","SID"`                                           Line 3 "Concurrent licenses`t`t`t`t`t: " $DefaultConCurrentLicenses
                                -Format $wdTableGrid `                                           Line 3 "If limit is exceeded`t`t`t`t`t: " $DefaultLicenseLimitNotify
                                -AutoFit $wdAutoFitFixed;    
                                    }
                                SetWordCellFormat -Collection $Table -Size 9 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
                                    Else
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 50;    
                                $Table.Columns.Item(3).Width = 250;    
                                    {
                                            Line 3 "Session Sharing`t`t`t`t`t`t: " $SessionSharing
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           Line 3 "Allow users to start only 1 instance of this application: " $PubItem.OneInstancePerUser.ToString()
                                            Line 3 "Concurrent licenses`t`t`t`t`t: " $ConCurrentLicenses
                                FindWordDocumentEnd                                           Line 3 "If limit is exceeded`t`t`t`t`t: " $LicenseLimitNotify
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }                                   }
     
                                    If($PubItem.InheritLicenseDefaultSettings)
                                    {
                                            Line 3 "Settings are replicated to all Sites`t`t`t: " $DefaultReplicateLicenseSettings.ToString()
                }                                   }
                If($Text)                                   Else
                {                                   {
                        Line 2 "Policy $($Policy.Name)"                                           Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateLicenseSettings.ToString()
                                    }
                        Line 0 ""                                   Line 0 ""
     
                        Line 2 "Policy"                                   Line 2 "Display"
                        Line 3 "Name`t   : " $Policy.Name                                   Line 3 "Inherit default settings`t`t`t`t: " $PubItem.InheritDisplayDefaultSettings.ToString()
                        Line 3 "Description: " $Policy.Description    
                        Line 0 ""    
                                    If($PubItem.InheritDisplayDefaultSettings)
                                    {
                        Line 2 "Apply policy to"                                           Line 3 "Wait until all RAS Universal Printers are redirected "
                        Line 3 "Name                                      Type   SID                                               "                                           Line 3 "before showing the application`t`t`t`t: " $DefaultWaitForPrinters
                        Line 3 "==================================================================================================="                                           Line 3 "Maximum time to wait is`t`t`t`t`t: " "$($DefaultWaitForPrintersTimeout) seconds"
                        #       1234567890123456789012345678901234567890SS12345SS12345678901234567890123456789012345678901234567890                                           Line 3 "Color Depth`t`t`t`t`t`t: " $DefaultColorDepth
                                            Line 3 "Start the application as maximized "
                                            Line 3 "when using mobile clients`t`t`t`t: " $DefaultStartMaximized
                                                          }
                        ForEach($Item in $Policy.UsersGroups)                                   Else
                        {                                   {
                                Line 3 ( "{0,-40}  {1,-5}  {2,-40}" -f `                                           Line 3 "Wait until all RAS Universal Printers are redirected "
                                $Item.Account, $Item.Type, $Item.Sid)                                           Line 3 "before showing the application`t`t`t`t: " $PubItem.WaitForPrinters.ToString()
                                            Line 3 "Maximum time to wait is`t`t`t`t`t: " "$($PubItem.WaitForPrintersTimeout.ToString()) seconds"
                                            Line 3 "Color Depth`t`t`t`t`t`t: " $ColorDepth
                                            Line 3 "Start the application as maximized "
                                            Line 3 "when using mobile clients`t`t`t`t: " $PubItem.StartMaximized.ToString()
                        }                                   }
     
                                    Line 3 "Settings are replicated to all Sites: " $PubItem.ReplicateDisplaySettings.ToString()
                        Line 0 ""                                   Line 0 ""
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 3 0 "Policy $($Policy.Name)"                                   WriteHTMLLine 3 0 "Information"
                        $rowdata = @()                                   $rowdata = @()
     
                        $columnHeaders = @("Name",($Script:htmlsb),$Policy.Name,$htmlwhite)                                   $columnHeaders = @("Windows Virtual Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
                        $rowdata += @(,("Description",($Script:htmlsb),$Policy.Description,$htmlwhite))                                   $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))
                        $msg = ""                                   $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))
                        $columnWidths = @("150","200")                                   $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))
                                    $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
                        WriteHTMLLine 0 0 ""    
                                    
                        $rowdata = @()                                   If(![String]::IsNullOrEmpty($PubItem.Parameters))
     
                        ForEach($Item in $Policy.UsersGroups)    
                        {                                   {
                                $rowdata += @(,(                                           $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))
                                $Item.Account,$htmlwhite,    
                                $Item.Type,$htmlwhite,    
                                $Item.Sid,$htmlwhite))    
                        }                                   }
                                    
                        $columnHeaders = @(                                   If($PubItem.EnableFileExtensions)
                        "Name",($Script:htmlsb),    
                        "Type",($Script:htmlsb),    
                        "SID",($Script:htmlsb))    
     
                        $msg = "Apply policy to"    
                        $columnWidths = @("200","50","300")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }                                   {
                                            $rowdata += @(,("Associate the following file extensions",($Script:htmlsb),"",$htmlwhite))
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tPolicy/Criteria"                                           ForEach($Item in $PubItem.FileExtensions)
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tPolicy/Criteria/Gateway criteria"    
     
                $GWType = ""    
                Switch($Policy.GWRule)    
                {                                           {
                        "AnyGW"                         {$GWType = "if Client is connected to any gateway"; Break}                                                   $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                        "ConnectedToGWs"        {$GWType = "if Client is connected to one of the following gateways"; Break}    
                        "NotConnectedToGWs"     {$GWType = "if Client is not connecteed to one of the following gateways"; Break}    
                        Default                         {$GWType = "Policy/Criteria/Gateway criteria type not found: $($Policy.GWRule)"; Break}    
                }                                           }
     
                $MACType = ""    
                Switch($Policy.MACRule)    
                {    
                        "AnyMAC"                        {$MACType = "to any MAC address"; Break}    
                        "AllowedMACs"           {$MACType = "if the Client's MAC address is one of the following"; Break}    
                        "NotAllowedMACs"        {$MACType = "if the Client's MAC address is not one of the following"; Break}    
                        Default                         {$MACType = "Policy/Criteria/Mac address criteria type not found: $($Policy.MACRule)"; Break}    
                }                                   }
                                    
                If($MSWord -or $PDF)                                   If($PubItem.InheritLicenseDefaultSettings)
                {                                   {
                        WriteWordLine 4 0 "Criteria"                                           If($DefaultOneInstancePerUser)
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Gateway criteria/Apply policy"; Value = $GWType; }) > $Null    
                        If($Policy.GWRule -ne "AnyGW")    
                        {                                           {
                                ForEach($GW in $Policy.GWList)                                                   $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))
                                            }
                                            Else
                                {                                           {
                                        $ScriptInformation.Add(@{Data = ""; Value = $GW; }) > $Null                                                   $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))
                                }                                           }
                                            $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$DefaultConCurrentLicenses,$htmlwhite))
                                            $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$DefaultLicenseLimitNotify,$htmlwhite))
                                            $rowdata += @(,("Session Sharing",($Script:htmlsb),$DefaultDisableSessionSharing,$htmlwhite))
                        }                                   }
                                                          Else
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/MAC address criteria/Apply policy"; Value = $MACType; }) > $Null    
                        If($Policy.MACRule -ne "AnyMAC")    
                        {                                   {
                                ForEach($MAC in $Policy.MACList)                                           If($PubItem.OneInstancePerUser)
                                {                                           {
                                        $ScriptInformation.Add(@{Data = ""; Value = $MAC; }) > $Null                                                   $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))
                                }                                           }
                                            Else
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))
                        }                                           }
                                            $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$ConCurrentLicenses,$htmlwhite))
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/Windows"; Value = $Policy.AllowedOSes.Windows.ToString(); }) > $Null                                           $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$LicenseLimitNotify,$htmlwhite))
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/iOS"; Value = $Policy.AllowedOSes.iOS.ToString(); }) > $Null                                           $rowdata += @(,("Session Sharing",($Script:htmlsb),$SessionSharing,$htmlwhite))
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/HTML5"; Value = $Policy.AllowedOSes.HTML5.ToString(); }) > $Null    
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/macOS"; Value = $Policy.AllowedOSes.Mac.ToString(); }) > $Null    
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/Android"; Value = $Policy.AllowedOSes.Android.ToString(); }) > $Null    
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/Chrome"; Value = $Policy.AllowedOSes.Chrome.ToString(); }) > $Null    
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/Linux"; Value = $Policy.AllowedOSes.Linux.ToString(); }) > $Null    
     
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 300;    
                        $Table.Columns.Item(2).Width = 200;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
                }                                   }
                If($Text)    
                                    $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))
                                    
                                    If($PubItem.PublishFrom -eq "Server")
                {                                   {
                        Line 2 "Criteria"                                           $cnt = -1
                        Line 0 ""                                           ForEach($Item in $PubItem.PublishFromServer)
                        Line 3 "Policy/Criteria/Gateway criteria/Apply policy: " $GWType    
                        If($Policy.GWRule -ne "AnyGW")    
                        {                                           {
                                ForEach($GW in $Policy.GWList)                                                   $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    If($cnt -eq 0)
                                {                                                   {
                                        Line 7 "  " $GW                                                           $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))
                                }                                                   }
                        }                                                   Else
                            
                        Line 3 "Policy/Criteria/MAC address criteria/Apply policy: " $MACType    
                        If($Policy.MACRule -ne "AnyMAC")    
                        {                                                   {
                                ForEach($MAC in $Policy.MACList)                                                           $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                                {    
                                        Line 7 "  " $MAC    
                                }                                                   }
                        }                                           }
     
                        Line 3 "Policy/Criteria/Parallels client criteria/Windows: " $Policy.AllowedOSes.Windows.ToString()    
                        Line 3 "Policy/Criteria/Parallels client criteria/iOS: " $Policy.AllowedOSes.iOS.ToString()    
                        Line 3 "Policy/Criteria/Parallels client criteria/HTML5: " $Policy.AllowedOSes.HTML5.ToString()    
                        Line 3 "Policy/Criteria/Parallels client criteria/macOS: " $Policy.AllowedOSes.Mac.ToString()    
                        Line 3 "Policy/Criteria/Parallels client criteria/Android: " $Policy.AllowedOSes.Android.ToString()    
                        Line 3 "Policy/Criteria/Parallels client criteria/Chrome: " $Policy.AllowedOSes.Chrome.ToString()    
                        Line 3 "Policy/Criteria/Parallels client criteria/Linux: " $Policy.AllowedOSes.Linux.ToString()    
                        Line 0 ""    
                }                                   }
                If($HTML)                                   ElseIf($PubItem.PublishFrom -eq "Group")
                {                                   {
                        $rowdata = @()    
                                            $cnt = -1
                        $columnHeaders = @("Policy/Criteria/Gateway criteria/Apply policy",($Script:htmlsb),$GWType,$htmlwhite)                                           ForEach($Item in $PubItem.PublishFromGroup)
                        If($Policy.GWRule -ne "AnyGW")    
                        {                                           {
                                ForEach($GW in $Policy.GWList)                                                   $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    If($cnt -eq 0)
                                {                                                   {
                                        $rowdata += @(,("",($Script:htmlsb),$GW,$htmlwhite))                                                           $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))
                                }                                                   }
                        }                                                   Else
                            
                        $rowdata += @(,("Policy/Criteria/MAC address criteria/Apply policy",($Script:htmlsb),$MACType,$htmlwhite))    
                        If($Policy.MACRule -ne "AnyMAC")    
                        {                                                   {
                                ForEach($MAC in $Policy.MACList)    
                                {    
                                        $rowdata += @(,("",($Script:htmlsb),$MAC,$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                                }                                                   }
                        }                                           }
     
                        $rowdata += @(,("Policy/Criteria/Parallels client criteria/Windows",($Script:htmlsb),$Policy.AllowedOSes.Windows.ToString(),$htmlwhite))    
                        $rowdata += @(,("Policy/Criteria/Parallels client criteria/iOS",($Script:htmlsb),$Policy.AllowedOSes.iOS.ToString(),$htmlwhite))    
                        $rowdata += @(,("Policy/Criteria/Parallels client criteria/HTML5",($Script:htmlsb),$Policy.AllowedOSes.HTML5.ToString(),$htmlwhite))    
                        $rowdata += @(,("Policy/Criteria/Parallels client criteria/macOS",($Script:htmlsb),$Policy.AllowedOSes.Mac.ToString(),$htmlwhite))    
                        $rowdata += @(,("Policy/Criteria/Parallels client criteria/Android",($Script:htmlsb),$Policy.AllowedOSes.Android.ToString(),$htmlwhite))    
                        $rowdata += @(,("Policy/Criteria/Parallels client criteria/Chrome",($Script:htmlsb),$Policy.AllowedOSes.Chrome.ToString(),$htmlwhite))    
                        $rowdata += @(,("Policy/Criteria/Parallels client criteria/Linux",($Script:htmlsb),$Policy.AllowedOSes.Linux.ToString(),$htmlwhite))    
                            
                        $msg = "Criteria"    
                        $columnWidths = @("400","300")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }                                   }
                                    Else
                If($MSWord -or $PDF)    
                {                                   {
                        [System.Collections.Hashtable[]] $SettingsWordTable = @();                                           $rowdata += @(,("Published from",($Script:htmlsb),"All Servers in Site",$htmlwhite))
                }                                   }
                If($HTML)    
                {    
                        $rowdata = @()    
                }    
 
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession" <>                                 If($PubItem.InheritShortcutDefaultSettings)
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection"    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Primary connection"    
                If($Policy.ClientPolicy.Session.PrimaryConnection.Enabled)    
                {                                   {
                        $txt = "Session/Connection/Primary connection/Name"                                           If($DefaultCreateShortcutOnDesktop -eq "True")
                        If($MSWord -or $PDF)    
                        {                                           {
                                $SettingsWordTable += @{                                                   $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.PrimaryConnection.Name;    
                                }                                           }
                        }                                           If($DefaultCreateShortcutInStartFolder -eq "True")
                        If($HTML)    
                        {                                           {
                                $rowdata += @(,(                                                   $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.PrimaryConnection.Name,$htmlwhite))    
                        }                                           }
                        If($Text)                                           If($DefaultCreateShortcutInStartUpFolder -eq "True")
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.PrimaryConnection.Name                                                   $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                        }                                           }
                            
                        $txt = "Session/Connection/Primary connection/Login/Auto Login"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.PrimaryConnection.AutoLogin.ToString();    
 
                        } <>                                 Else
                        If($HTML)    
                        {                                   {
                                $rowdata += @(,(                                           If($PubItem.CreateShortcutOnDesktop)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.PrimaryConnection.AutoLogin.ToString(),$htmlwhite))    
                        }    
                        If($Text)    
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.PrimaryConnection.AutoLogin.ToString()                                                   $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                        }                                           }
                                                                  If($PubItem.CreateShortcutInStartFolder)
                        $AuthType = ""    
                        Switch($Policy.ClientPolicy.Session.PrimaryConnection.AuthenticationType)    
                        {                                           {
                                "Credentials"   {$AuthType = "Credentials"; Break}                                                   $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))
                                "SingleSignOn"  {$AuthType = "Single Sign-On"; Break}    
                                "SmartCard"             {$AuthType = "Smart card"; Break}    
                                "Web"                   {$AuthType = "Web"; Break}    
                                Default                 {$AuthType = "Primary connection/Login/Authentication type not found: $($Policy.ClientPolicy.Session.PrimaryConnection.AuthenticationType)"; Break}    
                        }                                           }
                                                                  If($PubItem.CreateShortcutInStartUpFolder)
                        $txt = "Session/Connection/Primary connection/Login/Authentication type"    
                        If($MSWord -or $PDF)    
                        {                                           {
                                $SettingsWordTable += @{                                                   $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                Text = $txt;    
                                Value = $AuthType;    
                                }                                           }
                        }                                   }
                        If($HTML)    
                        {    
                                $rowdata += @(,(                                   If($PubItem.UserFilterEnabled -or
                                $txt,$htmlbold,                                      $PubItem.ClientFilterEnabled -or 
                                $AuthType,$htmlwhite))                                      $PubItem.IPFilterEnabled -or 
                        }                                      $PubItem.MACFilterEnabled -or 
                        If($Text)                                      $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                        {                                   {
                                OutputPolicySetting $txt $AuthType                                           $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))
                        }                                   }
 
                        If($Policy.ClientPolicy.Session.PrimaryConnection.AuthenticationType -eq "Credentials") <>                                 If($PubItem.UserFilterEnabled)
                        {                                   {
                                $txt = "Session/Connection/Primary connection/Login/Save password"                                           $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                If($MSWord -or $PDF)                                          
                                            ForEach($Item in $PubItem.AllowedUsers)
                                {                                           {
                                        $SettingsWordTable += @{                                                   $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))
                                        Text = $txt;    
                                        Value = $Policy.ClientPolicy.Session.PrimaryConnection.SavePassword.ToString();    
 
                                If($HTML) <>                                 If($PubItem.IPFilterEnabled)
 
                                        $rowdata += @(,( <>                                         $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                        $txt,$htmlbold,    
                                        $Policy.ClientPolicy.Session.PrimaryConnection.SavePassword.ToString(),$htmlwhite))    
                                }    
                                If($Text)                                           If($PubItem.AllowedIP4s.Count -gt 0)
                                {                                           {
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.PrimaryConnection.SavePassword.ToString()                                                   ForEach($item in $PubItem.AllowedIP4s)
                                }    
     
                                $txt = "Session/Connection/Primary connection/Login/Domain"    
                                If($MSWord -or $PDF)    
                                {                                                   {
                                        $SettingsWordTable += @{                                                           If($item.From -eq $item.To)
                                        Text = $txt;    
                                        Value = $Policy.ClientPolicy.Session.PrimaryConnection.Domain;    
                                        }    
                                }    
                                If($HTML)    
                                {                                                           {
                                        $rowdata += @(,(                                                                   $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                        $txt,$htmlbold,    
                                        $Policy.ClientPolicy.Session.PrimaryConnection.Domain,$htmlwhite))    
                                }                                                           }
                                If($Text)                                                           Else
                                {                                                           {
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.PrimaryConnection.Domain                                                                   $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                }                                                           }
                        }                                                   }
                }                                           }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Secondary connections"                                           If($PubItem.AllowedIP6s.Count -gt 0)
                If($Policy.ClientPolicy.Session.SecondaryConnections.Enabled)    
                {                                           {
                        $txt = "Session/Connection/Secondary connections/Secondary connections"                                                   ForEach($item in $PubItem.AllowedIP6s)
                        $cnt = 0    
                            
                        ForEach($Item in $Policy.ClientPolicy.Session.SecondaryConnections.ConnectionList)    
                        {                                                   {
                                $cnt++    
                                $GWMode = ""    
                                Switch($Item.Mode)                                                           If($item.From -eq $item.To)
                                {                                                           {
                                        "DirectMode"            {$GWMode = "Direct Mode"; Break}                                                                   $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                        "DirectSSLMode"         {$GWMode = "Direct SSL Mode"; Break}    
                                        "GatewayMode"           {$GWMode = "Gateway Mode"; Break}    
                                        "GatewaySSLMode"        {$GWMode = "Gateway SSL Mode"; Break}    
                                        Default                         {$GWMode = "Secondary connections/Secondary connections/Mode not found: $($Item.Mode)"; Break}    
                                }                                                           }
                                                                          Else
                                If($cnt -eq 1)    
                                {                                                           {
                                        If($MSWord -or $PDF)                                                                   $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                        {                                                           }
                                                $SettingsWordTable += @{    
                                                Text = $txt;    
                                                Value = "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())";    
 
                                        If($HTML) <>                                 }
                                    If($PubItem.ClientFilterEnabled)
                                        {                                   {
                                                $rowdata += @(,(                                           $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                                $txt,$htmlbold,    
                                                "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())",$htmlwhite))    
                                        }                                          
                                        If($Text)                                           ForEach($item in $PubItem.AllowedClients)
 
                                                OutputPolicySetting $txt "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())" <>                                                 $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
 
                                Else <>                                 If($PubItem.MACFilterEnabled)
 
                                        If($MSWord -or $PDF) <>                                         $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
 
                                                $SettingsWordTable += @{ <>                                                 $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                                Text = "";    
                                                Value = "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())";    
                                                }                                           }
                                        }                                   }
                                        If($HTML)                                   If($PubItem.GatewayFilterEnabled)
                                        {                                   {
                                                $rowdata += @(,(                                           $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                                "",$htmlbold,    
                                                "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())",$htmlwhite))    
                                        }                                          
                                        If($Text)                                           ForEach($item in $PubItem.AllowedGateways)
 
                                                OutputPolicySetting "`t`t`t`t`t`t`t      " "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())" <>                                                 $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
 
  <>                                 If($PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))
                        }                                           }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
                }                                           }
                                                          
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Reconnection"                                           If($PubItem.AllowedOSes.iOS)
                If($Policy.ClientPolicy.Session.Reconnection.Enabled)    
                {                                           {
                        $txt = "Session/Connection/Reconnection/Reconnection/Reconnect if connection is dropped"                                                   $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
                        If($MSWord -or $PDF)                                           }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                        {                                           {
                                $SettingsWordTable += @{                                                   $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.Reconnection.EnableReconnection.ToString();    
                                }                                           }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))
                        }                                           }
                        If($HTML)                                          
                                            If($PubItem.AllowedOSes.WebPortal)
                        {                                           {
                                $rowdata += @(,(                                                   $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.Reconnection.EnableReconnection.ToString(),$htmlwhite))    
                        }                                           }
                        If($Text)                                          
                                            If($PubItem.AllowedOSes.Windows)
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Reconnection.EnableReconnection.ToString()                                                   $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))
                        }                                           }
                                                                  
                        $txt = "Session/Connection/Reconnection/Reconnection/Connection retries"                                           If($PubItem.AllowedOSes.Wyse)
                        If($MSWord -or $PDF)    
                        {                                           {
                                $SettingsWordTable += @{                                                   $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.Reconnection.ConnectionRetries.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)    
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                        {                                   {
                                $rowdata += @(,(                                           $cnt++
                                $txt,$htmlbold,                                           $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                $Policy.ClientPolicy.Session.Reconnection.ConnectionRetries.ToString(),$htmlwhite))    
                        }                                           
                        If($Text)                                           If($cnt -eq 0)
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Reconnection.ConnectionRetries.ToString()                                                   $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))
                        }                                           }
                                                                  Else
                        $txt = "Session/Connection/Reconnection/Connection banner/Show if reconnection is not established within (seconds)"    
                        If($MSWord -or $PDF)    
                        {                                           {
                                $SettingsWordTable += @{                                                   $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.Reconnection.ConnectionBannerDelay.ToString();    
                                }                                           }
                        }                                   }
                            
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Sites"
                                    $rowdata = @()
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                        If($HTML)                                           If($cnt -eq 0)
                        {                                           {
                                $rowdata += @(,(                                                   $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.Reconnection.ConnectionBannerDelay.ToString(),$htmlwhite))    
                        }                                           }
                        If($Text)                                           Else
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Reconnection.ConnectionBannerDelay.ToString()                                                   $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                        }                                           }
                }                                   }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Computer name"                                   $msg = ""
                If($Policy.ClientPolicy.Session.ComputerName.Enabled)                                   $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Publish from"
                                    $rowdata = @()
                                    If($PubItem.PublishFrom -eq "Server")
                {                                   {
                        $txt = "Session/Connection/Computer name/Computer name/Override computer name"                                           $cnt = -1
                        If($MSWord -or $PDF)                                           ForEach($Item in $PubItem.PublishFromServer)
                        {                                           {
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.ComputerName.OverrideComputerName;    
                                }                                                   $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                        }                                                   
                        If($HTML)                                                   If($cnt -eq 0)
                        {                                                   {
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.ComputerName.OverrideComputerName,$htmlwhite))                                                           $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)
                        }                                                   }
                        If($Text)                                                   Else
                        {                                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.ComputerName.OverrideComputerName                                                           $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                        }                                                   }
                }                                           }
                                                  }
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Advanced settings"                                   ElseIf($PubItem.PublishFrom -eq "Group")
                If($Policy.ClientPolicy.Session.ConnectionAdvancedSettings.Enabled)    
                {                                   {
                        $txt = "Session/Connection/Advanced settings/Connection/Connection timeout (seconds)"                                           $cnt = -1
                        If($MSWord -or $PDF)                                           ForEach($Item in $PubItem.PublishFromGroup)
                        {                                           {
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionTimeout.ToString();    
                                }                                                   $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                        }                                                   
                        If($HTML)                                                   If($cnt -eq 0)
                        {                                                   {
                                $rowdata += @(,(                                                           $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionTimeout.ToString(),$htmlwhite))    
                        }                                                   }
                        If($Text)                                                   Else
                        {                                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionTimeout.ToString()                                                           $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                        }                                                   }
                            
                        $txt = "Session/Connection/Advanced settings/Connection banner/Show if connection is not established within (seconds)"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionBannerDelay.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)                                   Else
                        {                                   {
                                $rowdata += @(,(                                           $columnHeaders = @("$PublishedFrom",($Script:htmlsb),"",$htmlwhite)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionBannerDelay.ToString(),$htmlwhite))    
                        }                                   }
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Application"
                                    $rowdata = @()
     
                                    $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Run",($Script:htmlsb),$WinType,$htmlwhite))
                                    $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))
                                    $rowdata += @(,("Start in",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))
                                    $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))
                                    $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
                                    $rowdata += @(,("Exclude from session prelaunch",($Script:htmlsb),$PubItem.ExcludePrelaunch.ToString(),$htmlwhite))
     
                                    $msg = "Application"
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                                    
                                    OutputPubItemFilters $PubItem "HTML"
                                    
                                    OutputPubItemShortcuts $PubItem "HTML" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
     
                                    WriteHTMLLine 3 0 "File extensions"
                                    $rowdata = @()
                                    $columnHeaders = @("Associate File Extensions",($Script:htmlsb),$PubItem.EnableFileExtensions.ToString(),$htmlwhite)
                                    
                                    If($PubItem.EnableFileExtensions)
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.FileExtensions)
                                            {
                                                    $cnt++
                                                    
                        If($Text)                                                   If($cnt -eq 0)
                        {                                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionBannerDelay.ToString()                                                           $rowdata += @(,("Extension",($Script:htmlsb),$Item,$htmlwhite))
                        }                                                   }
                                                                          Else
                        $txt = "Session/Connection/Advanced settings/Desktop/Show if published application does not start within (seconds)"    
                        If($MSWord -or $PDF)    
                        {                                                   {
                                $SettingsWordTable += @{                                                           $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                Text = $txt;                                                   }
                                Value = $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ShowDesktopTimeout.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)    
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    $rowdata = @()
                                    $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ReplicateFileExtensionSettings.ToString(),$htmlwhite)
     
                                    $msg = ""
                                    $columnWidths = @("183","100")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "License"
                                    $rowdata = @()
                                    $columnHeaders = @("Inherit default settings",($Script:htmlsb),$PubItem.InheritLicenseDefaultSettings.ToString(),$htmlwhite)
     
                                    If($PubItem.InheritLicenseDefaultSettings)
                        {                                   {
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ShowDesktopTimeout.ToString(),$htmlwhite))                                           $rowdata += @(,("Session Sharing",($Script:htmlsb),$DefaultDisableSessionSharing,$htmlwhite))
                                            If($DefaultOneInstancePerUser)
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))
                        }                                           }
                        If($Text)                                           Else
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ShowDesktopTimeout.ToString()                                                   $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))
                        }                                           }
                                            $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$DefaultConCurrentLicenses,$htmlwhite))
                                            $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$DefaultLicenseLimitNotify,$htmlwhite))
                }                                   }
                                                  Else
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Web authentication"    
                If($Policy.ClientPolicy.Session.WebAuthentication.Enabled)    
                {                                   {
                        $txt = "Session/Connection/Web authentication/Web authentication/Use default OS browser"                                           $rowdata += @(,("Session Sharing",($Script:htmlsb),$SessionSharing,$htmlwhite))
                        If($MSWord -or $PDF)                                           If($PubItem.OneInstancePerUser)
                        {                                           {
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.WebAuthentication.DefaultOsBrowser.ToString();                                                   $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))
                                }                                           }
                        }                                           Else
                        If($HTML)    
                        {                                           {
                                $rowdata += @(,(                                                   $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))
                                $txt,$htmlbold,                                           }
                                $Policy.ClientPolicy.Session.WebAuthentication.DefaultOsBrowser.ToString(),$htmlwhite))                                           $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$ConCurrentLicenses,$htmlwhite))
                                            $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$LicenseLimitNotify,$htmlwhite))
                        }                                   }
                        If($Text)    
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    $rowdata = @()
                                    If($PubItem.InheritLicenseDefaultSettings)
                        {                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.WebAuthentication.DefaultOsBrowser.ToString()                                           $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$DefaultReplicateLicenseSettings.ToString(),$htmlwhite)
                        }                                   }
                            
                        If($Policy.ClientPolicy.Session.WebAuthentication.DefaultOsBrowser -eq $False)    
                        {                                   Else
                                $txt = "Session/Connection/Web authentication/Web authentication/Open browser window to complete log out"    
                                If($MSWord -or $PDF)    
 
                                        $SettingsWordTable += @{ <>                                         $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ReplicateLicenseSettings.ToString(),$htmlwhite)
                                        Text = $txt;    
                                        Value = $Policy.ClientPolicy.Session.WebAuthentication.OpenBrowserOnLogout.ToString();    
                                        }                                   }
                                }    
                                    $msg = ""
                                    $columnWidths = @("183","100")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                                If($HTML)    
                                    WriteHTMLLine 3 0 "Display"
                                    $rowdata = @()
                                    $columnHeaders = @("Inherit default settings",($Script:htmlsb),$PubItem.InheritDisplayDefaultSettings.ToString(),$htmlwhite)
     
                                    If($PubItem.InheritDisplayDefaultSettings)
 
                                        $rowdata += @(,( <>                                         $rowdata += @(,("Wait until all RAS Universal Printers are redirected before showing the application",($Script:htmlsb),$DefaultWaitForPrinters,$htmlwhite))
                                        $txt,$htmlbold,                                           $rowdata += @(,("Maximum time to wait is",($Script:htmlsb),"$($DefaultWaitForPrintersTimeout) seconds",$htmlwhite))
                                        $Policy.ClientPolicy.Session.WebAuthentication.OpenBrowserOnLogout.ToString(),$htmlwhite))                                           $rowdata += @(,("Color Depth",($Script:htmlsb),$DefaultColorDepth,$htmlwhite))
                                            $rowdata += @(,("Start the application as maximized when using mobile clients",($Script:htmlsb),$DefaultStartMaximized,$htmlwhite))
 
                                If($Text) <>                                 Else
 
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.WebAuthentication.OpenBrowserOnLogout.ToString() <>                                         $rowdata += @(,("Wait until all RAS Universal Printers are redirected before showing the application",($Script:htmlsb),$PubItem.WaitForPrinters.ToString(),$htmlwhite))
                                            $rowdata += @(,("Maximum time to wait is",($Script:htmlsb),"$($PubItem.WaitForPrintersTimeout.ToString()) seconds",$htmlwhite))
                                            $rowdata += @(,("Color Depth",($Script:htmlsb),$ColorDepth,$htmlwhite))
                                            $rowdata += @(,("Start the application as maximized when using mobile clients",($Script:htmlsb),$PubItem.StartMaximized.ToString(),$htmlwhite))
 
  -+  
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    $rowdata = @()
                                    $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ReplicateDisplaySettings.ToString(),$htmlwhite)
     
                                    $msg = ""
                                    $columnWidths = @("183","100")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
 
                <>                 ElseIf($PubItem.Type -eq "WVDDesktop")
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Multifactor authentication"    
                If($Policy.ClientPolicy.Session.MultiFactorAuthentication.Enabled)    
 
                        $txt = "Session/Connection/Multifactor authentication/Multifactor authentication/Remember last used method" <>                         $DesktopSize = "Unable to determine"
                        If($MSWord -or $PDF)                           If($PubItem.DesktopSize -eq "FullScreen")
 
                                $SettingsWordTable += @{ <>                                 $DesktopSize = "Full Screen"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.MultiFactorAuthentication.RememberLastUsedMethod.ToString();    
                                }                           }
                            ElseIf($PubItem.DesktopSize -eq "UseAvailableArea")
                            {
                                    $DesktopSize = "Use available area"
 
                        If($HTML) <>                         Else
 
                                $rowdata += @(,( <>                                 $DesktopSize = "$($PubItem.Width.ToString())x$($PubItem.Height.ToString())"
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.MultiFactorAuthentication.RememberLastUsedMethod.ToString(),$htmlwhite))    
 
                        If($Text) <>                        
                            Switch ($PubItem.PublishFrom)
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.MultiFactorAuthentication.RememberLastUsedMethod.ToString() <>                                 "All"           {$PublishedFrom = "All Servers in Site"; Break}
                                    "Group"         {$PublishedFrom = "Groups:"; Break}
                                    "Server"        {$PublishedFrom = "Individual Servers:"; Break}
                                    Default         {$PublishedFrom = "Unable to determine Published From: $($PubItem.PublishFrom)"; Break}
 
                } <>  
                                          
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Session prelaunch"    
                If($Policy.ClientPolicy.Session.SessionPreLaunch.Enabled)                           If($PubItem.AllowMultiMonitor -eq "UseClientSettings")
                {                           {
                        $SPMode = ""                                   $AllowMultiMonitor = "Use Client Settings"
                        Switch($Policy.ClientPolicy.Session.SessionPreLaunch.PreLaunchMode)                           }
                            Else
 
                                "Off"                           {$SPMode = "Off"; Break} <>                                 $AllowMultiMonitor = $PubItem.AllowMultiMonitor.ToString()
                                "Basic"                         {$SPMode = "Basic"; Break}    
                                "MachineLearning"       {$SPMode = "Machine Learning"; Break}    
                                Default                         {$SPMode = "Connection/Session prelaunch mode not found: $($Policy.ClientPolicy.Session.SessionPreLaunch.PreLaunchMode)"; Break}    
 
                        $txt = "Session/Connection/Session prelaunch/Session prelaunch/Mode" +-  
 
                                $SettingsWordTable += @{ <>                                 WriteWordLine 3 0 "Information"
                                Text = $txt;                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                Value = $SPMode;                                   $ScriptInformation.Add(@{Data = "Windows Virtual Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null
                                    
                                    If($PubItem.PublishFrom -eq "Server")
                                }                                   {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromServer)
                        }                                           {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    
                        If($HTML)                                                   If($cnt -eq 0)
                        {                                                   {
                                $rowdata += @(,(                                                           $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null
                                $txt,$htmlbold,    
                                $SPMode,$htmlwhite))    
                        }                                                   }
                        If($Text)                                                   Else
                        {                                                   {
                                OutputPolicySetting $txt $SPMode                                                           $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                        }                                                   }
                                                                  }
                        $txt = "Session/Connection/Session prelaunch/Session prelaunch/Exclude sessions prelaunch"                                   }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
                                    {
                        $cnt = 0                                           $cnt = -1
                                                                  ForEach($Item in $PubItem.PublishFromGroup)
                        ForEach($Item in $Policy.ClientPolicy.Session.SessionPreLaunch.PreLaunchExclude)    
                        {                                           {
                                $cnt++                                                   $cnt++
                                $TmpArray = $Item.Split(":")                                                   $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                $Day      = $TmpArray[0].ToString()                                                   If($cnt -eq 0)
                                $MonthNum = $TmpArray[1]    
                                    
                                Switch($MonthNum)    
                                {                                                   {
                                        1               {$Month = "January"; Break}    
                                        2               {$Month = "February"; Break}    
                                        3               {$Month = "March"; Break}    
                                        4               {$Month = "April"; Break}    
                                        5               {$Month = "May"; Break}    
                                        6               {$Month = "June"; Break}    
                                        7               {$Month = "July"; Break}    
                                        8               {$Month = "August"; Break}    
                                        9               {$Month = "September"; Break}    
                                        10              {$Month = "October"; Break}    
                                        11              {$Month = "November"; Break}    
                                        12              {$Month = "December"; Break}    
                                        Default {$Month = "Exclude sessions prelaunch Month not founf: $($MonthNum)"; Break}                                                           $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null
                                }                                                   }
                                                                                  Else
                                If($cnt -eq 1)    
                                {                                                   {
                                        If($MSWord -or $PDF)                                                           $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                                                    }
                                            }
                                    }
                                    Else
                                        {                                   {
                                                $SettingsWordTable += @{                                           $ScriptInformation.Add(@{Data = "Published from"; Value = "All Servers in Site"; }) > $Null
                                                Text = $txt;    
                                                Value = "Day: $Day   Month: $Month";    
                                                }                                   }
     
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
 
                                        If($HTML) <>                                         If($DefaultCreateShortcutInStartFolder -eq "True")
 
                                                $rowdata += @(,( <>                                                 $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null
                                                $txt,$htmlbold,    
                                                "Day: $Day   Month: $Month",$htmlwhite))    
 
                                        If($Text) <>                                         If($DefaultCreateShortcutInStartUpFolder -eq "True")
 
                                                OutputPolicySetting $txt "Day: $Day   Month: $Month" <>                                                 $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
 
                                        If($MSWord -or $PDF) <>                                         If($PubItem.CreateShortcutOnDesktop)
 
                                                $SettingsWordTable += @{ <>                                                 $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                                Text = "";    
                                                Value = "Day: $Day   Month: $Month";    
                                                }    
 
                                        If($HTML) <>                                         If($PubItem.CreateShortcutInStartFolder)
 
                                                $rowdata += @(,( <>                                                 $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null
                                                "",$htmlbold,    
                                                "Day: $Day   Month: $Month",$htmlwhite))    
 
                                        If($Text) <>                                         If($PubItem.CreateShortcutInStartUpFolder)
 
                                                OutputPolicySetting "`t`t`t`t`t`t`t`t`t`t " "Day: $Day   Month: $Month" <>                                                 $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
 
                                 <>  
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                        }                                   {
                                                                  $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null
                }                                   }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Local proxy address"                                   If($PubItem.UserFilterEnabled)
                If($Policy.ClientPolicy.Session.LocalProxyAddress.Enabled)    
                {                                   {
                        $txt = "Session/Connection/Local proxy address/Local proxy address/Use 127.0.0.1 IP address when using Gateway mode in VPN scenarios"                                           $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null
                        If($MSWord -or $PDF)                                          
                                            ForEach($Item in $PubItem.AllowedUsers)
                        {                                           {
                                $SettingsWordTable += @{                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.LocalProxyAddress.UseLocalHostProxyIP.ToString();    
                                }                                           }
                        }                                   }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null
                        If($HTML)    
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                        {                                           {
                                $rowdata += @(,(                                                   ForEach($item in $PubItem.AllowedIP4s)
                                $txt,$htmlbold,                                                   {
                                $Policy.ClientPolicy.Session.LocalProxyAddress.UseLocalHostProxyIP.ToString(),$htmlwhite))                                                           If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                        }                                                           }
                        If($Text)                                                           Else
                        {                                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.LocalProxyAddress.UseLocalHostProxyIP.ToString()                                                                   $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                        }                                                           }
                }                                                   }
                                            }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display"                                           If($PubItem.AllowedIP6s.Count -gt 0)
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display/Settings"                                           {
                If($Policy.ClientPolicy.Session.Settings.Enabled)                                                   ForEach($item in $PubItem.AllowedIP6s)
                {                                                   {
                        $GAMode = ""                                                           If($item.From -eq $item.To)
                        Switch($Policy.ClientPolicy.Session.Settings.GraphicsAcceleration)    
                        {                                                           {
                                "AVCAdaptive"           {$GAMode = "AVC Adaptive"; Break}                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                "Basic"                         {$GAMode = "Basic"; Break}    
                                "None"                          {$GAMode = "None"; Break}    
                                "RemoteFx"                      {$GAMode = "RemoteFX (default, forces 32-bit color depth)"; Break}    
                                "RemoteFxAdaptive"      {$GAMode = "RemoteFx Adaptive"; Break}    
                                Default                         {$GAMode = "Display settings/Acceleration mode not found: $($Policy.ClientPolicy.Session.Settings.GraphicsAcceleration)"; Break}    
                        }                                                           }
                                                            Else
                        $txt = "Session/Display/Settings/Display settings/Acceleration mode"    
                        If($MSWord -or $PDF)    
                        {                                                           {
                                $SettingsWordTable += @{                                                                   $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                Text = $txt;    
                                Value = $GAMode;    
                                }                                                           }
                        }                                                   }
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $GAMode,$htmlwhite))    
                        }                                           }
                        If($Text)    
                        {    
                                OutputPolicySetting $txt $GAMode    
                        }                                   }
                                                          If($PubItem.ClientFilterEnabled)
                        $ColorDepth = ""    
                        Switch($Policy.ClientPolicy.Session.Settings.ColorDepths)    
                        {                                   {
                                "Colors256"                             {$ColorDepth = "256 Colors"; Break}    
                                "HighColor15Bit"                {$ColorDepth = "High Color (15 bit)"; Break}    
                                "HighColor16Bit"                {$ColorDepth = "High Color (16 bit)"; Break}    
                                "TrueColor24Bit"                {$ColorDepth = "True Color (24 bit)"; Break}    
                                "HighestQuality32Bit"   {$ColorDepth = "Highest Quality (32 bit)"; Break}                                           $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null
                                Default                                 {$ColorDepth = "Display settings/Color depth not found: $($Policy.ClientPolicy.Session.Settings.ColorDepths)"; Break}    
                        }    
                                            
                        $txt = "Session/Display/Settings/Display settings/Color depth"                                           ForEach($item in $PubItem.AllowedClients)
                        If($MSWord -or $PDF)    
                        {                                           {
                                $SettingsWordTable += @{                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                Text = $txt;    
                                Value = $ColorDepth;    
                                }                                           }
                        }                                   }
                        If($HTML)                                   If($PubItem.MACFilterEnabled)
                        {                                   {
                                $rowdata += @(,(                                           $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null
                                $txt,$htmlbold,    
                                $ColorDepth,$htmlwhite))    
                        }                                           
                        If($Text)                                           ForEach($item in $PubItem.AllowedMACs)
                        {                                           {
                                OutputPolicySetting $txt $ColorDepth                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                        }                                           }
                }                                   }
                                    If($PubItem.GatewayFilterEnabled)
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display/Multi-monitor"    
                If($Policy.ClientPolicy.Session.MultiMonitor.Enabled)    
                {                                   {
                        $txt = "Session/Display/Multi-monitor/Multi-monitor/Use all monitors for desktop session (if applicable)"                                           $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null
                        If($MSWord -or $PDF)                                          
                                            ForEach($item in $PubItem.AllowedGateways)
                        {                                           {
                                $SettingsWordTable += @{                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.MultiMonitor.UseAllMonitors.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)                                   If($PubItem.OSFilterEnabled)
                        {                                   {
                                $rowdata += @(,(                                           $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null
                                $txt,$htmlbold,                                          
                                $Policy.ClientPolicy.Session.MultiMonitor.UseAllMonitors.ToString(),$htmlwhite))                                           If($PubItem.AllowedOSes.Android)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null
                        }                                           }
                        If($Text)                                          
                                            If($PubItem.AllowedOSes.Chrome)
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.MultiMonitor.UseAllMonitors.ToString()                                                   $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
                        }                                           }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
                }                                           }
                                                          
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display/Published applications"                                           If($PubItem.AllowedOSes.Linux)
                If($Policy.ClientPolicy.Session.PublishedApplications.Enabled)    
                {                                           {
                        $txt = "Session/Display/Published applications/Published applications/Use primary monitor only"                                                   $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null
                        If($MSWord -or $PDF)                                           }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                        {                                           {
                                $SettingsWordTable += @{                                                   $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.PublishedApplications.UsePrimaryMonitor.ToString();    
                                }                                           }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
                        }                                           }
                        If($HTML)                                          
                                            If($PubItem.AllowedOSes.Windows)
                        {                                           {
                                $rowdata += @(,(                                                   $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.PublishedApplications.UsePrimaryMonitor.ToString(),$htmlwhite))    
                        }                                           }
                        If($Text)                                          
                                            If($PubItem.AllowedOSes.Wyse)
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.PublishedApplications.UsePrimaryMonitor.ToString()                                                   $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null
                        }                                           }
                }                                   }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display/Desktop options"                                   $cnt =-1
                If($Policy.ClientPolicy.Session.DesktopOptions.Enabled)                                   ForEach($Site in $PubItem.PublishToSite)
                {                                   {
                        $SmartSize = ""                                           $cnt++
                        Switch($Policy.ClientPolicy.Session.DesktopOptions.SmartSizing)                                           $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                        {                                           {
                                "Disabled"      {$SmartSize = "Disabled"; Break}                                                   $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null
                                "Scale"         {$SmartSize = "Scale (fit to window)"; Break}    
                                "Resize"        {$SmartSize = "Resize (update resolution)"; Break}    
                                Default         {$SmartSize = "Desktop options/Smart-sizing not found: $($Policy.ClientPolicy.Session.DesktopOptions.SmartSizing)"; Break}    
                        }                                           }
                                            Else
                        $txt = "Session/Display/Desktop options/Desktop options/Smart-sizing"    
                        If($MSWord -or $PDF)    
                        {                                           {
                                $SettingsWordTable += @{                                                   $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                Text = $txt;    
                                Value = $SmartSize;    
                                }                                           }
                        }                                   }
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
                        If($HTML)    
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Sites"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                        {                                   {
                                $rowdata += @(,(                                           $cnt++
                                $txt,$htmlbold,                                           $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                $SmartSize,$htmlwhite))    
                        }                                           
                        If($Text)                                           If($cnt -eq 0)
                        {                                           {
                                OutputPolicySetting $txt $SmartSize                                                   $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null
                        }                                           }
                                                                  Else
                        $txt = "Session/Display/Desktop options/Desktop options/Embed desktop in launcher"    
                        If($MSWord -or $PDF)    
                        {                                           {
                                $SettingsWordTable += @{                                                   $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.DesktopOptions.EmbedDesktop.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)    
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Publish from"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    If($PubItem.PublishFrom -eq "Server")
                        {                                   {
                                $rowdata += @(,(                                           $cnt = -1
                                $txt,$htmlbold,                                           ForEach($Item in $PubItem.PublishFromServer)
                                $Policy.ClientPolicy.Session.DesktopOptions.EmbedDesktop.ToString(),$htmlwhite))    
                        }                                           {
                                                    $cnt++
                                                    
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    
                        If($Text)                                                   If($cnt -eq 0)
                        {                                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.DesktopOptions.EmbedDesktop.ToString()                                                           $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null
                        }                                                   }
                                                    Else
                        $txt = "Session/Display/Desktop options/Desktop options/Span desktop across all monitors"    
                        If($MSWord -or $PDF)    
                        {                                                   {
                                $SettingsWordTable += @{                                                           $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                                Text = $txt;                                                   }
                                Value = $Policy.ClientPolicy.Session.DesktopOptions.SpanDesktops.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)                                   ElseIf($PubItem.PublishFrom -eq "Group")
                        {                                   {
                                $rowdata += @(,(                                           $cnt = -1
                                $txt,$htmlbold,                                           ForEach($Item in $PubItem.PublishFromGroup)
                                $Policy.ClientPolicy.Session.DesktopOptions.SpanDesktops.ToString(),$htmlwhite))    
                        }                                           {
                                                    $cnt++
                                                    
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    
                        If($Text)                                                   If($cnt -eq 0)
                        {                                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.DesktopOptions.SpanDesktops.ToString()                                                           $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null
                        }                                                   }
                                                    Else
                        $ConnBar = ""    
                        Switch($Policy.ClientPolicy.Session.DesktopOptions.FullScreenBar)    
                        {                                                   {
                                "DoNotShow"             {$ConnBar = "Do not show"; Break}                                                           $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                                "ShowPinned"    {$ConnBar = "Show pinned"; Break}    
                                "ShowUnPinned"  {$ConnBar = "Show unpinned"; Break}    
                                Default                 {$ConnBar = "Desktop options/Connection bar in full screen not found: $($Policy.ClientPolicy.Session.DesktopOptions.FullScreenBar)"; Break}    
                        }                                                   }
     
                        $txt = "Session/Display/Desktop options/Desktop options/Connection bar in full screen"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $ConnBar;    
                                }                                           }
                        }                                   }
                        If($HTML)                                   Else
                        {                                   {
                                $rowdata += @(,(                                           $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = ""; }) > $Null
                                $txt,$htmlbold,                                   }
                                $ConnBar,$htmlwhite))    
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Desktop"
                                    WriteWordLine 4 0 "Desktop"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Connect to administrative session"; Value = $PubItem.ConnectToConsole.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Exclude from session prelaunch"; Value = $PubItem.ExcludePrelaunch.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                                    
                                    WriteWordLine 4 0 "Properties"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Desktop size"; Value = $DesktopSize; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Multi-Monitor"; Value = $AllowMultiMonitor; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                                    
                                    OutputPubItemFilters $PubItem "MSWordPDF"
                                    
                                    OutputPubItemShortcuts $PubItem "MSWordPDF" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
 
                                OutputPolicySetting $txt $ConnBar <>                                 Line 2 "Information"
                                    Line 3 "Windows Virtual Desktop`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
                                    Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description
                                    Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod
                                    Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate
                                    Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()
                                    Line 3 "Desktop Size`t`t`t`t`t`t: " $DesktopSize
                        }                                   
                                    If($PubItem.PublishFrom -eq "Server")
                }                                   {
                                            $cnt = -1
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display/Browser"                                           ForEach($Item in $PubItem.PublishFromServer)
                If($Policy.ClientPolicy.Session.Browser.Enabled)    
                {                                           {
                        $BrowserOpen = ""                                                   $cnt++
                        Switch($Policy.ClientPolicy.Session.Browser.BrowserOpenIn)                                                   $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    If($cnt -eq 0)
                        {                                                   {
                                "SameTab"       {$BrowserOpen = "Same tab"; Break}                                                           Line 3 "Published from`t`t`t`t`t`t: " ItemName
                                "NewTab"        {$BrowserOpen = "New tab"; Break}    
                                Default         {$BrowserOpen = "Browser/Open applications in not found: $($Policy.ClientPolicy.Session.Browser.BrowserOpenIn)"; Break}    
                        }                                                   }
                                                    Else
                        $txt = "Session/Display/Browser/Browser/Open applications in"    
                        If($MSWord -or $PDF)    
                        {                                                   {
                                $SettingsWordTable += @{                                                           Line 10 $ItemName
                                Text = $txt;                                                   }
                                Value = $BrowserOpen;    
                                }                                           }
                        }                                   }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromGroup)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                        If($HTML)                                                   If($cnt -eq 0)
                        {                                                   {
                                $rowdata += @(,(                                                           Line 3 "Published from`t`t`t`t`t`t: " ItemName
                                $txt,$htmlbold,    
                                $BrowserOpen,$htmlwhite))    
                        }                                                   }
                        If($Text)                                                   Else
                        {                                                   {
                                OutputPolicySetting $txt $BrowserOpen                                                           Line 10 $ItemName
                        }                                                   }
                }                                           }
                                    }
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Printing"    
                If($Policy.ClientPolicy.Session.Printing.Enabled)    
                {                                   Else
                        $PrintTechUse = ""    
                        Switch($Policy.ClientPolicy.Session.Printing.DefaultPrinterTech)    
                        {                                   {
                                "None"                                                                                  {$PrintTechUse = "None"; Break}                                           Line 3 "Published from`t`t`t`t`t`t: " "All Servers in Site"
                                "RasUniversalPrintingTechnology"                                {$PrintTechUse = "RAS Universal Printing technology"; Break}    
                                "MicrosoftBasicPrintingTechnology"                              {$PrintTechUse = "Microsoft basic Printing Redirection technology"; Break}    
                                "RasUniversalPrintingAndMsBasicTechnologies"    {$PrintTechUse = "RAS Universal Printing and MS Basic Redirection technologies"; Break}    
                                Default                                                                                 {$PrintTechUse = "Technology/Use not found: $($Policy.ClientPolicy.Session.Printing.DefaultPrinterTech)"; Break}    
                        }                                   }
 
                        $txt = "Session/Printing/Technology/Use" <>                                 If($PubItem.InheritShortcutDefaultSettings)
                        If($MSWord -or $PDF)    
                        {                                   {
                                $SettingsWordTable += @{                                           If($DefaultCreateShortcutOnDesktop -eq "True")
                                Text = $txt;    
                                Value = $PrintTechUse;    
                                }                                           {
                                                    Line 3 "Create shortcut on desktop"
                        }                                           }
                        If($HTML)                                           If($DefaultCreateShortcutInStartFolder -eq "True")
                        {                                           {
                                $rowdata += @(,(                                                   Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"
                                $txt,$htmlbold,    
                                $PrintTechUse,$htmlwhite))    
                        }                                           }
                        If($Text)                                           If($DefaultCreateShortcutInStartUpFolder -eq "True")
                        {                                           {
                                OutputPolicySetting $txt $PrintTechUse                                                   Line 3 "Create shortcut in Auto Start Folder"
                        }                                           }
                                    }
                        If( $Policy.ClientPolicy.Session.Printing.DefaultPrinterTech -eq "RasUniversalPrintingTechnology" -or                                    Else
                                $Policy.ClientPolicy.Session.Printing.DefaultPrinterTech -eq "RasUniversalPrintingAndMsBasicTechnologies" )    
                        {                                   {
                                $RedirectPrinters = ""                                           If($PubItem.CreateShortcutOnDesktop)
                                Switch($Policy.ClientPolicy.Session.Printing.RedirectPrinters)    
                                {                                           {
                                        "All"                   {$RedirectPrinters = "All"; Break}                                                   Line 3 "Create shortcut on desktop"
                                        "DefaultOnly"   {$RedirectPrinters = "Default only"; Break}    
                                        "SpecificOnly"  {$RedirectPrinters = "Specific only"; Break}    
                                        Default                 {$RedirectPrinters = "RAS Universal Printing/Redirect printers not found: $($Policy.ClientPolicy.Session.Printing.RedirectPrinters)"; Break}    
                                }                                           }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                $txt = "Session/Printing/RAS Universal Printing/Redirect printers"                                                   Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"
                                If($MSWord -or $PDF)                                           }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                {                                           {
                                        $SettingsWordTable += @{    
                                        Text = $txt;    
                                        Value = $RedirectPrinters;                                                   Line 3 "Create shortcut in Auto Start Folder"
 
                                If($HTML) <>  
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
 
                                        $rowdata += @(,( <>                                         Line 3 "Own Filters"
                                        $txt,$htmlbold,    
                                        $RedirectPrinters,$htmlwhite))    
 
                                If($Text) <>  
                                    If($PubItem.UserFilterEnabled)
 
                                        OutputPolicySetting $txt $RedirectPrinters <>                                         Line 3 " User filtering is enabled"
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    Line 10 "  " $Item.Account
                                }                                           }
                                            Line 0 ""
                                                                  }
                                If($Policy.ClientPolicy.Session.Printing.RedirectPrinters -eq "SpecificOnly")                                   If($PubItem.IPFilterEnabled)
 
                                        ForEach($Item in $Policy.ClientPolicy.Session.Printing.RedirectPrintersList) <>                                         Line 3 " IP filtering is enabled"
                                            If($PubItem.AllowedIP4s.Count -gt 0)
 
                                                If($MSWord -or $PDF) <>                                                 ForEach($item in $PubItem.AllowedIP4s)
 
                                                        $SettingsWordTable += @{ <>                                                         If($item.From -eq $item.To)
                                                        Text = "";                                                           {
                                                        Value = "Name: $($Item)";                                                                   Line 10 "  " $item.From
 
  <>                                                         Else
                                                            {
                                                                    Line 10 "  $($item.From) - $($item.To)"
                                                }                                                           }
                                                If($HTML)    
                                                {                                                   }
                                                        $rowdata += @(,(    
                                                        "",$htmlbold,    
                                                        "Name: $($Item)",$htmlwhite))    
                                                }                                           }
                                                If($Text)    
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
 
                                                        OutputPolicySetting "`t`t`t`t`t`t`t " "Name: $($Item)" <>                                                         If($item.From -eq $item.To)
                                                            {
                                                                    Line 10 "  " $item.From
                                                }                                                           }
                                                            Else
                                                            {
                                                                    Line 10 "  $($item.From) - $($item.To)"
                                        }                                                           }
                                }                                                   }
                        }                                           }
                                            Line 0 ""
                }                                   }
                                                  If($PubItem.ClientFilterEnabled)
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Scanning"    
                If($Policy.ClientPolicy.Session.Scanning.Enabled)    
                {                                   {
                        $ScanTechUse = ""                                           Line 3 " Client filtering is enabled"
                        Switch($Policy.ClientPolicy.Session.Scanning.ScanTech)                                          
                                            ForEach($item in $PubItem.AllowedClients)
                        {                                           {
                                "None"                  {$ScanTechUse = "None"; Break}                                                   Line 10 "  " $Item
                                "WIA"                   {$ScanTechUse = "WIA"; Break}                                           }
                                "TWAIN"                 {$ScanTechUse = "TWAIN"; Break}                                           Line 0 ""
                                "WIAandTWAIN"   {$ScanTechUse = "WIA and TWAIN"; Break}    
                                Default                 {$ScanTechUse = "Technology/Use not found: $($Policy.ClientPolicy.Session.Scanning.ScanTech)"; Break}    
                        }                                   }
                                    If($PubItem.MACFilterEnabled)
                                    {
                        $txt = "Session/Scanning/Technology/Use"                                           Line 3 " MAC filtering is enabled"
                        If($MSWord -or $PDF)                                          
                                            ForEach($item in $PubItem.AllowedMACs)
                        {                                           {
                                $SettingsWordTable += @{                                                   Line 10 "  " $Item
                                Text = $txt;    
                                Value = $ScanTechUse;    
                                }                                           }
                                            Line 0 ""
                        }                                   }
                        If($HTML)                                   If($PubItem.GatewayFilterEnabled)
                        {                                   {
                                $rowdata += @(,(                                           Line 3 " Gateway filtering is enabled"
                                $txt,$htmlbold,    
                                $ScanTechUse,$htmlwhite))    
                        }                                           
                        If($Text)                                           ForEach($item in $PubItem.AllowedGateways)
                        {                                           {
                                OutputPolicySetting $txt $ScanTechUse                                                   Line 10 "  " $Item
                        }                                           }
                                            Line 0 ""
                                    }
                        If( $Policy.ClientPolicy.Session.Scanning.ScanTech -ne "None" )                                   If($PubItem.OSFilterEnabled)
                        {                                   {
                                $RedirectScanners = ""                                           Line 3 " Client device operating system filtering is enabled"
                                Switch($Policy.ClientPolicy.Session.Scanning.ScanRedirect)                                          
                                            If($PubItem.AllowedOSes.Android)
                                {                                           {
                                        "All"                   {$RedirectScanners = "All"; Break}                                                   Line 10 "  Android"
                                        "SpecificOnly"  {$RedirectScanners = "Specific only"; Break}    
                                        Default                 {$RedirectScanners = "RAS Universal Scanning/Redirect scanners not found: $($Policy.ClientPolicy.Session.Scanning.ScanRedirect)"; Break}    
                                }                                           }
                                            
                                $txt = "Session/Printing/RAS Universal Scanning/Redirect scanners"                                           If($PubItem.AllowedOSes.Chrome)
                                If($MSWord -or $PDF)    
                                {                                           {
                                        $SettingsWordTable += @{                                                   Line 10 "  Chrome OS"
                                        Text = $txt;    
                                        Value = $RedirectScanners;    
 
                                } <>                                         
                                If($HTML)                                           If($PubItem.AllowedOSes.iOS)
                                {                                           {
                                        $rowdata += @(,(                                                   Line 10 "  iOS/iPadOS"
                                        $txt,$htmlbold,    
                                        $RedirectScanners,$htmlwhite))    
                                }                                           }
                                If($Text)                                          
                                            If($PubItem.AllowedOSes.Linux)
                                {                                           {
                                        OutputPolicySetting $txt $RedirectScanners                                                   Line 10 "  Linux"
                                }                                           }
                                                                          
                                If($Policy.ClientPolicy.Session.Scanning.ScanRedirect -eq "SpecificOnly")                                           If($PubItem.AllowedOSes.Mac)
                                {                                           {
                                        $ScannerArray = @()                                                   Line 10 "  macOS"
                                        If($Policy.ClientPolicy.Session.Scanning.ScanTech -eq "WIA")                                           }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
 
                                                $ScannerArray = $Policy.ClientPolicy.Session.Scanning.ScanListWia <>                                                 Line 10 "  RAS Web Portal"
 
                                        Else <>                                        
                                            If($PubItem.AllowedOSes.Windows)
 
                                                $ScannerArray = $Policy.ClientPolicy.Session.Scanning.ScanListTwain <>                                                 Line 10 "  Windows"
 
                                        ForEach($Item in $ScannerArray) <>                                         If($PubItem.AllowedOSes.Wyse)
 
                                                If($MSWord -or $PDF) <>                                                 Line 10 "  Wyse"
                                                {    
                                                        $SettingsWordTable += @{    
                                                        Text = "";    
                                                        Value = "Name: $($Item)";    
                                                        }                                           }
                                            Line 0 ""
                                                }                                   }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                                If($HTML)                                           If($cnt -eq 0)
                                                {                                           {
                                                        $rowdata += @(,(                                                   Line 3 "Available in Site(s)`t`t`t`t`t: " $SiteName
                                                        "",$htmlbold,    
                                                        "Name: $($Item)",$htmlwhite))    
                                                }                                           }
                                                If($Text)                                           Else
                                                {                                           {
                                                        OutputPolicySetting "`t`t`t`t`t`t`t " "Name: $($Item)"                                                   Line 10 $SiteName
                                                }                                           }
                                        }                                   }
                                    Line 0 ""
     
                                    Line 2 "Sites"
                                    Line 3 "This published item will be available from the following Sites"
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            Line 10 $SiteName
 
  <>                                 Line 0 ""
     
                                    Line 2 "Publish from"
                                    Line 3 $PublishedFrom
                                    If($PubItem.PublishFrom -eq "Server")
                                    {
                                            ForEach($Item in $PubItem.PublishFromServer)
                                            {
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    Line 6 $ItemName
                        }                                           }
                }                                   }
                                                  ElseIf($PubItem.PublishFrom -eq "Group")
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Audio"    
                If($Policy.ClientPolicy.Session.Audio.Enabled)    
                {                                   {
                        $AudioMode = ""                                           ForEach($Item in $PubItem.PublishFromGroup)
                        Switch($Policy.ClientPolicy.Session.Audio.AudioModes)    
                        {                                           {
                                "BringToThisComputer"   {$AudioMode = "Bring to this computer"; Break}                                                   $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                "DoNotPlay"                             {$AudioMode = "Do not play"; Break}                                                   Line 5 $ItemName
                                "LeaveAtRemoteComputer" {$AudioMode = "Leave at remote computer"; Break}    
                                Default                                 {$AudioMode = "Remote audio playback/Where not found: $($Policy.ClientPolicy.Session.Audio.AudioModes)"; Break}    
                        }                                           }
     
                        $txt = "Session/Audio/Remote audio playback/Where"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $AudioMode;    
 
  -+                                 Line 0 ""
                                    
                                    Line 2 "Desktop"
                                    Line 3 "Desktop"
                                    Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name
                                    Line 4 "Description`t`t`t`t`t: " $PubItem.Description
                                    Line 4 "Connect to administrative session`t`t: " $PubItem.ConnectToConsole.ToString()
                                    Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()
                                    Line 4 "Exclude from session prelaunch`t`t`t: " $PubItem.ExcludePrelaunch.ToString()
                                    Line 0 ""
                                    
                                    Line 3 "Properties"
                                    Line 4 "Desktop size`t`t`t`t`t: " $DesktopSize
                                    Line 4 "Multi-Monitor`t`t`t`t`t: " $AllowMultiMonitor
                                    Line 0 ""
     
                                    OutputPubItemFilters $PubItem "Text"
                                    
                                    OutputPubItemShortcuts $PubItem "Text" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
 
  <>                                 WriteHTMLLine 3 0 "Information"
                                $rowdata += @(,(                                   $rowdata = @()
                                $txt,$htmlbold,                                   $columnHeaders = @("Windows Virtual Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
                                $AudioMode,$htmlwhite))                                   $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))
                                    
                                    If($PubItem.PublishFrom -eq "Server")
                        }                                   {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromServer)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                        If($Text)                                                   If($cnt -eq 0)
                        {                                                   {
                                OutputPolicySetting $txt $AudioMode                                                           $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))
                        }                                                   }
                                                    Else
                        $AudioQuality = ""    
                        Switch($Policy.ClientPolicy.Session.Audio.AudioQuality)    
                        {                                                   {
                                "AdjustDynamically"                     {$AudioQuality = "Dynamically adjust based on available bandwidth"; Break}                                                           $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                                "UseMediumQuality"                      {$AudioQuality = "Always use medium audio quality"; Break}    
                                "UseUncompressedQuality"        {$AudioQuality = "Always use uncompressed audio quality"; Break}    
                                Default                                         {$AudioQuality = "Remote audio playback/Quality not found: $($Policy.ClientPolicy.Session.Audio.AudioQuality)"; Break}    
                        }                                                   }
     
                        $txt = "Session/Audio/Remote audio playback/Quality"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $AudioQuality;    
                                }                                           }
                        }                                   }
                        If($HTML)                                   ElseIf($PubItem.PublishFrom -eq "Group")
                        {                                   {
                                $rowdata += @(,(                                           $cnt = -1
                                $txt,$htmlbold,                                           ForEach($Item in $PubItem.PublishFromGroup)
                                $AudioQuality,$htmlwhite))    
                        }                                           {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                        If($Text)                                                   If($cnt -eq 0)
                        {                                                   {
                                OutputPolicySetting $txt $AudioQuality                                                           $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))
                        }                                                   }
                                                    Else
                        $txt = "Session/Audio/Remote audio recording/Enable recording (if applicable)"    
                        If($MSWord -or $PDF)    
                        {                                                   {
                                $SettingsWordTable += @{                                                           $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.Audio.AudioRec.ToString();    
                                }                                                   }
                        }                                           }
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.Audio.AudioRec.ToString(),$htmlwhite))    
                        }                                   }
                        If($Text)                                   Else
                        {                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Audio.AudioRec.ToString()                                           $rowdata += @(,("Published from",($Script:htmlsb),"All Servers in Site",$htmlwhite))
                        }                                   }
                }    
                                                  If($PubItem.InheritShortcutDefaultSettings)
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Keyboard"    
                If($Policy.ClientPolicy.Session.Keyboard.Enabled)    
                {                                   {
                        $KeyboardWindow = ""                                           If($DefaultCreateShortcutOnDesktop -eq "True")
                        Switch($Policy.ClientPolicy.Session.Keyboard.KeyboardWindow)    
                        {                                           {
                                "LocalComputer"         {$KeyboardWindow = "On the local computer"; Break}                                                   $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                "RemoteComputer"        {$KeyboardWindow = "On the remote computer"; Break}    
                                "FullScreenMode"        {$KeyboardWindow = "In full screen mode only"; Break}    
                                Default                         {$KeyboardWindow = "Keyboard/Apply Windows key combinations for desktops only not found: $($Policy.ClientPolicy.Session.Keyboard.KeyboardWindow)"; Break}    
                        }                                           }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                        $txt = "Session/Keyboard/Keyboard/Apply Windows key combinations for desktops only"                                                   $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))
                        If($MSWord -or $PDF)                                           }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                        {                                           {
                                $SettingsWordTable += @{                                                   $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                Text = $txt;    
                                Value = $KeyboardWindow;    
                                }                                           }
                        }                                   }
                        If($HTML)                                   Else
                        {                                   {
                                $rowdata += @(,(                                           If($PubItem.CreateShortcutOnDesktop)
                                $txt,$htmlbold,                                           {
                                $KeyboardWindow,$htmlwhite))                                                   $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                        }                                           }
                        If($Text)                                           If($PubItem.CreateShortcutInStartFolder)
                        {                                           {
                                OutputPolicySetting $txt $KeyboardWindow                                                   $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))
                        }                                           }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                        $txt = "Session/Keyboard/Keyboard/Send Unicode characters"    
                        If($MSWord -or $PDF)    
                        {                                           {
                                $SettingsWordTable += @{                                                   $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.Keyboard.SendUnicodeChars.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)    
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                        {                                   {
                                $rowdata += @(,(                                           $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.Keyboard.SendUnicodeChars.ToString(),$htmlwhite))    
                        }                                   }
                        If($Text)    
                                    If($PubItem.UserFilterEnabled)
                        {                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Keyboard.SendUnicodeChars.ToString()                                           $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))
                        }                                           }
                }                                   }
                                                  If($PubItem.IPFilterEnabled)
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources"    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Clipboard"    
                If($Policy.ClientPolicy.Session.Clipboard.Enabled)    
                {                                   {
                        $ClipboardRedir = ""                                           $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                        Switch($Policy.ClientPolicy.Session.Clipboard.ClipboardDirection)    
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                        {                                           {
                                "ClientToServer"        {$ClipboardRedir = "Client to server only"; Break}                                                   ForEach($item in $PubItem.AllowedIP4s)
                                "ServerToClient"        {$ClipboardRedir = "Server to client only"; Break}    
                                "Bidirectional"         {$ClipboardRedir = "Bidirectional"; Break}    
                                "None"                          {$ClipboardRedir = "Disabled"; Break}    
                                Default                         {$ClipboardRedir = "Clipboard/Clipboard redirection not found: $($Policy.ClientPolicy.Session.Clipboard.ClipboardDirection)"; Break}    
                        }                                                   {
                                                            If($item.From -eq $item.To)
                        $txt = "Session/Local devices and resources/Clipboard/Clipboard/Clipboard redirection"    
                        If($MSWord -or $PDF)    
                        {                                                           {
                                $SettingsWordTable += @{                                                                   $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                Text = $txt;    
                                Value = $ClipboardRedir;    
                                }                                                           }
                        }                                                           Else
                        If($HTML)    
                        {                                                           {
                                $rowdata += @(,(                                                                   $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                $txt,$htmlbold,    
                                $ClipboardRedir,$htmlwhite))    
                        }                                                           }
                        If($Text)    
                        {    
                                OutputPolicySetting $txt $ClipboardRedir    
                        }                                                   }
                }                                           }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Disk drives"                                           If($PubItem.AllowedIP6s.Count -gt 0)
                If($Policy.ClientPolicy.Session.DiskDrives.Enabled)    
                {                                           {
                        $txt = "Session/Local devices and resources/Disk drives/Disk drives/Allow disk drives redirection"                                                   ForEach($item in $PubItem.AllowedIP6s)
                        If($MSWord -or $PDF)    
                        {                                                   {
                                $SettingsWordTable += @{                                                           If($item.From -eq $item.To)
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.DiskDrives.RedirectDrives.ToString();    
                                }                                                           {
                                                                    $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                        }                                                           }
                        If($HTML)                                                           Else
                        {                                                           {
                                $rowdata += @(,(                                                                   $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.DiskDrives.RedirectDrives.ToString(),$htmlwhite))    
                        }                                                           }
                        If($Text)    
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.DiskDrives.RedirectDrives.ToString()    
                        }                                                   }
     
                        $txt = "Session/Local devices and resources/Disk drives/Disk drives/Use all disk drives available"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.DiskDrives.UseAllDrives.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)                                   If($PubItem.ClientFilterEnabled)
                        {                                   {
                                $rowdata += @(,(                                           $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.DiskDrives.UseAllDrives.ToString(),$htmlwhite))    
                        }                                           
                        If($Text)                                           ForEach($item in $PubItem.AllowedClients)
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.DiskDrives.UseAllDrives.ToString()                                                   $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                        }                                           }
                                    }
                        If($Policy.ClientPolicy.Session.DiskDrives.UseAllDrives)                                   If($PubItem.MACFilterEnabled)
                        {                                   {
                                If($MSWord -or $PDF)                                           $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                {                                           {
                                        $SettingsWordTable += @{                                                   $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                        Text = "";    
                                        Value = "Drives A through Z";    
 
                                If($HTML) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        $rowdata += @(,( <>                                         $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                        "",$htmlbold,    
                                        "Drives A through Z",$htmlwhite))    
                                }                                           
                                If($Text)                                           ForEach($item in $PubItem.AllowedGateways)
                                {                                           {
                                        OutputPolicySetting "`t`t`t`t`t`t`t`t`t`t`t   " "Drives A through Z"                                                   $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                }                                           }
                        }                                   }
                        Else                                   If($PubItem.OSFilterEnabled)
                        {                                   {
                                ForEach($Item in $Policy.ClientPolicy.Session.DiskDrives.RedirectToDrives)                                           $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            If($PubItem.AllowedOSes.Android)
                                {                                           {
                                        If($MSWord -or $PDF)                                                   $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
 
                                                $SettingsWordTable += @{ <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
                                                Text = "";    
                                                Value = $Item;    
                                                }                                           }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                        If($HTML) <>                                        
                                            If($PubItem.AllowedOSes.Linux)
 
                                                $rowdata += @(,( <>                                                 $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))
                                                "",$htmlbold,    
                                                $Item,$htmlwhite))    
 
                                        If($Text) <>                                        
                                            If($PubItem.AllowedOSes.Mac)
 
                                                OutputPolicySetting "`t`t`t`t`t`t`t`t`t`t`t  " $Item <>                                                 $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))
 
  <>                                         
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
                                }                                           }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))
                        }                                           }
                                            
                        $txt = "Session/Local devices and resources/Disk drives/Disk drives/Use also disk drives that I plug in later"                                           If($PubItem.AllowedOSes.Wyse)
                        If($MSWord -or $PDF)    
                        {                                           {
                                $SettingsWordTable += @{                                                   $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.DiskDrives.DynamicDrives.ToString();    
                                }                                           }
                        }                                   }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                        If($HTML)                                           If($cnt -eq 0)
                        {                                           {
                                $rowdata += @(,(                                                   $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.DiskDrives.DynamicDrives.ToString(),$htmlwhite))    
                        }                                           }
                        If($Text)                                           Else
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.DiskDrives.DynamicDrives.ToString()                                                   $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                        }                                           }
                }                                   }
                                          
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Devices"                                   $msg = ""
                If($Policy.ClientPolicy.Session.Devices.Enabled)                                   $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Sites"
                                    $rowdata = @()
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                {                                   {
                        $txt = "Session/Local devices and resources/Devices/Devices/Allow devices redirection"                                           $cnt++
                        If($MSWord -or $PDF)                                           $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                        {                                           {
                                $SettingsWordTable += @{                                                   $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)
                                Text = $txt;                                           }
                                Value = $Policy.ClientPolicy.Session.Devices.RedirectDevices.ToString();                                           Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                                }                                           }
                        }                                   }
                        If($HTML)    
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Publish from"
                                    $rowdata = @()
                                    If($PubItem.PublishFrom -eq "Server")
                        {                                   {
                                $rowdata += @(,(                                           $cnt = -1
                                $txt,$htmlbold,                                           ForEach($Item in $PubItem.PublishFromServer)
                                $Policy.ClientPolicy.Session.Devices.RedirectDevices.ToString(),$htmlwhite))    
                        }                                           {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    
                        If($Text)                                                   If($cnt -eq 0)
                        {                                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Devices.RedirectDevices.ToString()                                                           $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)
                        }                                                   }
                                                    Else
                        $txt = "Session/Local devices and resources/Devices/Devices/Use all devices available"    
                        If($MSWord -or $PDF)    
                        {                                                   {
                                $SettingsWordTable += @{                                                           $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                                Text = $txt;                                                   }
                                Value = $Policy.ClientPolicy.Session.Devices.UseAllDevices.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)                                   ElseIf($PubItem.PublishFrom -eq "Group")
                        {                                   {
                                $rowdata += @(,(                                           $cnt = -1
                                $txt,$htmlbold,                                           ForEach($Item in $PubItem.PublishFromGroup)
                                $Policy.ClientPolicy.Session.Devices.UseAllDevices.ToString(),$htmlwhite))    
                        }                                           {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    
                        If($Text)                                                   If($cnt -eq 0)
                        {                                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Devices.UseAllDevices.ToString()                                                           $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)
                        }                                                   }
                                                    Else
                        $txt = "Session/Local devices and resources/Devices/Devices/Use also devices that I plug in later"    
                        If($MSWord -or $PDF)    
                        {                                                   {
                                $SettingsWordTable += @{                                                           $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                                Text = $txt;                                                   }
                                Value = $Policy.ClientPolicy.Session.Devices.DynamicDevices.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)                                   Else
                        {                                   {
                                $rowdata += @(,(                                           $columnHeaders = @("$PublishedFrom",($Script:htmlsb),"",$htmlwhite)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.Devices.DynamicDevices.ToString(),$htmlwhite))    
                        }                                   }
                        If($Text)    
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Devices.DynamicDevices.ToString()                                   WriteHTMLLine 3 0 "Desktop"
                                    $rowdata = @()
     
                                    $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Connect to administrative session",($Script:htmlsb),$PubItem.ConnectToConsole.ToString(),$htmlwhite))
                                    $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
                                    $rowdata += @(,("Exclude from session prelaunch",($Script:htmlsb),$PubItem.ExcludePrelaunch.ToString(),$htmlwhite))
     
                                    $msg = "Desktop"
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                                    
                                    $rowdata = @()
                                    $columnHeaders = @("Desktop size",($Script:htmlsb),$DesktopSize,$htmlwhite)
                                    $rowdata += @(,("Multi-Monitor",($Script:htmlsb),$AllowMultiMonitor,$htmlwhite))
     
                                    $msg = "Properties"
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    OutputPubItemFilters $PubItem "HTML"
                                    
                                    OutputPubItemShortcuts $PubItem "HTML" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
 
                 <>  
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Video capture devices"    
                #can't find    
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Ports"    
                If($Policy.ClientPolicy.Session.Ports.Enabled)    
                {    
                        $txt = "Session/Local devices and resources/Ports/Allow LPT and COM ports redirection"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.Ports.RedirectCOMPorts.ToString();    
                                }           }
                        }   }
                        If($HTML)    
    Function OutputPubItemFilters
                        {   {
                                $rowdata += @(,(           Param([object] $PubItem, [string] $OutputType)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.Ports.RedirectCOMPorts.ToString(),$htmlwhite))    
                        }          
                        If($Text)           If($OutputType -eq "MSWordPDF")
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Ports.RedirectCOMPorts.ToString()                   WriteWordLine 3 0 "Filtering"
                    If(!($PubItem.UserFilterEnabled))
                        }                   {
                            WriteWordLine 0 0 "User filtering not enabled"
                            WriteWordLine 0 0 ""
 
                <>                 Else
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Smart cards"    
                If($Policy.ClientPolicy.Session.SmartCards.Enabled)    
 
  <>                         WriteWordLine 0 0 "User filtering is enabled"
                            WriteWordLine 0 0 ""
                            WriteWordLine 0 0 "Allow the following Users:" -FontSize 9 -Italics $True
     
                        $txt = "Session/Local devices and resources/Smart cards/Allow smart cards redirection"                           $ScriptInformation = New-Object System.Collections.ArrayList
                        If($MSWord -or $PDF)                           $NameTable = @()
                            
                            ForEach($item in $PubItem.AllowedUsers)
 
                                $SettingsWordTable += @{ <>                                 $NameTable += @{
                                    User = $item.Account;
                                Text = $txt;                                   Type = $item.Type;
                                Value = $Policy.ClientPolicy.Session.SmartCards.RedirectSmartCards.ToString();                                   SID  = $item.Sid
 
                        If($HTML) <>  
                            If($NameTable.Count -gt 0)
 
                                $rowdata += @(,( <>                                 $Table = AddWordTable -Hashtable $NameTable `
                                $txt,$htmlbold,                                   -Columns User,Type,SID `
                                    -Headers "User", "Type", "SID" `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitContent;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                $Policy.ClientPolicy.Session.SmartCards.RedirectSmartCards.ToString(),$htmlwhite))                                   SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
 
                        If($Text) <>  
                            If(validObject $PubItem UserFilterReplicate)
 
  <>                                 $ScriptInformation = New-Object System.Collections.ArrayList
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.SmartCards.RedirectSmartCards.ToString()                                   $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.UserFilterReplicate.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 100;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
 
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Windows touch input" <>                 If(!($PubItem.ClientFilterEnabled))
                If($Policy.ClientPolicy.Session.WindowsTouchInput.Enabled)                   {
                            WriteWordLine 0 0 "Client device name filtering not enabled"
                            WriteWordLine 0 0 ""
                    }
                    Else
 
  <>                         WriteWordLine 0 0 "Client device name filtering is enabled"
                            WriteWordLine 0 0 ""
                        $txt = "Session/Local devices and resources/Windows touch input/Allow Windows touch input redirection"                           WriteWordLine 0 0 "Allow the following Clients:" -FontSize 9 -Italics $True
                        If($MSWord -or $PDF)    
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $NameTable = @()
                            
                            ForEach($item in $PubItem.AllowedClients)
 
                                $SettingsWordTable += @{ <>                                 $NameTable += @{
                                Text = $txt;                                   Client = $item;
                                Value = $Policy.ClientPolicy.Session.WindowsTouchInput.TouchInput.ToString();    
 
                        If($HTML) <>  
                            If($NameTable.Count -gt 0)
 
                                $rowdata += @(,( <>                                 $Table = AddWordTable -Hashtable $NameTable `
                                $txt,$htmlbold,                                   -Columns Client `
                                    -Headers "Client" `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitContent;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                $Policy.ClientPolicy.Session.WindowsTouchInput.TouchInput.ToString(),$htmlwhite))                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
 
                        If($Text) <>  
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ClientFilterReplicate.ToString(); }) > $Null
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.WindowsTouchInput.TouchInput.ToString()                           $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                        }                   }
                    If(!($PubItem.OSFilterEnabled))
                    {
                            WriteWordLine 0 0 "Client device operating system filtering not enabled"
                            WriteWordLine 0 0 ""
 
                <>                 Else
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/File transfer"    
                If($Policy.ClientPolicy.Session.FileTransfer.Enabled)    
 
  <>                         WriteWordLine 0 0 "Client device operating system filtering is enabled"
                        $FileTransfer = ""                           WriteWordLine 0 0 ""
                            WriteWordLine 0 0 "Allow access to clients running on the following operating system:" -FontSize 9 -Italics $True
                        Switch($Policy.ClientPolicy.Session.FileTransfer.FileTransferMode)                           $ScriptInformation = New-Object System.Collections.ArrayList
                            If($PubItem.AllowedOSes.Android)
 
                                "ClientToServer"        {$FileTransfer = "Client to server only"; Break} <>                                 $ScriptInformation.Add(@{Data = "Android"; Value = "Enabled"; }) > $Null
                                "ServerToClient"        {$FileTransfer = "Server to client only"; Break}    
                                "Bidirectional"         {$FileTransfer = "Bidirectional"; Break}    
                                "None"                          {$FileTransfer = "Disabled"; Break}    
                                Default                         {$FileTransfer = "File transfer/Allow file transfer mode not found: $($Policy.ClientPolicy.Session.FileTransfer.FileTransferMode)"; Break}    
 
  <>                         Else
                        $txt = "Session/Local devices and resources/File transfer/Allow file transfer"    
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $ScriptInformation.Add(@{Data = "Android"; Value = "Disabled"; }) > $Null
                                Text = $txt;    
                                Value = $FileTransfer;    
                                }                           }
                        }                          
                        If($HTML)                           If($PubItem.AllowedOSes.Chrome)
 
                                $rowdata += @(,( <>                                 $ScriptInformation.Add(@{Data = "Chrome OS"; Value = "Enabled"; }) > $Null
                                $txt,$htmlbold,    
                                $FileTransfer,$htmlwhite))    
 
                        If($Text) <>                         Else
 
                                OutputPolicySetting $txt $FileTransfer <>                                 $ScriptInformation.Add(@{Data = "Chrome OS"; Value = "Disabled"; }) > $Null
 
                } <>  
                                          
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Experience"                           If($PubItem.AllowedOSes.iOS)
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Experience/Performance"    
                If($Policy.ClientPolicy.Session.Performance.Enabled)    
                {    
                        $ConnSpeed = ""    
                        Switch($Policy.ClientPolicy.Session.Performance.NetType)    
 
                                "Modem"                                                 {$ConnSpeed = "Modem (56Kbps)"; Break} <>                                 $ScriptInformation.Add(@{Data = "iOS/iPadOS"; Value = "Enabled"; }) > $Null
                                "LowSpeedBroadband"                             {$ConnSpeed = "Low speed broadband (256 Kbps - 2 Mbps)"; Break}    
                                "Satellite"                                             {$ConnSpeed = "Satellite (2 Mbps - 16 Mbps with high latency)"; Break}    
                                "HighSpeedBroadband"                    {$ConnSpeed = "High speed broadband (2 Mbps - 16 Mbps)"; Break}    
                                "WAN"                                                   {$ConnSpeed = "WAN (10 Mbps or higher with high latency)"; Break}    
                                "LAN"                                                   {$ConnSpeed = "LAN (10 Mbps or higher)"; Break}    
                                "DetectConnectionQualityAuto"   {$ConnSpeed = "Detect connection quality automatically"; Break}    
                                Default                                                 {$ConnSpeed = "Performance/Choose your connection speed to optimize performance mode not found: $($Policy.ClientPolicy.Session.Performance.NetType)"; Break}    
 
  <>                         Else
                        $txt = "Session/Experience/Performance/Performance/Choose your connection speed to optimize performance"    
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $ScriptInformation.Add(@{Data = "iOS/iPadOS"; Value = "Disabled"; }) > $Null
                                Text = $txt;    
                                Value = $ConnSpeed;    
                                }                           }
                        }                          
                        If($HTML)                           If($PubItem.AllowedOSes.Linux)
 
                                $rowdata += @(,( <>                                 $ScriptInformation.Add(@{Data = "Linux"; Value = "Enabled"; }) > $Null
                                $txt,$htmlbold,    
                                $ConnSpeed,$htmlwhite))    
 
                        If($Text) <>                         Else
 
                                OutputPolicySetting $txt $ConnSpeed <>                                 $ScriptInformation.Add(@{Data = "Linux"; Value = "Disabled"; }) > $Null
 
  <>                         
                        If($Policy.ClientPolicy.Session.Performance.NetType -ne "DetectConnectionQualityAuto")                           If($PubItem.AllowedOSes.Mac)
 
                                $txt = "Session/Experience/Performance/Performance/Desktop backgroup" <>                                 $ScriptInformation.Add(@{Data = "macOS"; Value = "Enabled"; }) > $Null
                                If($MSWord -or $PDF)                           }
                            Else
                                {                           {
                                        $SettingsWordTable += @{                                   $ScriptInformation.Add(@{Data = "macOS"; Value = "Disabled"; }) > $Null
                                        Text = $txt;    
                                        Value = $Policy.ClientPolicy.Session.Performance.DesktopBackground.ToString();    
                                        }                           }
                                }                          
                                If($HTML)                           If($PubItem.AllowedOSes.WebPortal)
                                {                           {
                                        $rowdata += @(,(                                   $ScriptInformation.Add(@{Data = "User Portal (Web Client)"; Value = "Enabled"; }) > $Null
                                        $txt,$htmlbold,    
                                        $Policy.ClientPolicy.Session.Performance.DesktopBackground.ToString(),$htmlwhite))    
                                }                           }
                                If($Text)                           Else
                                {                           {
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.DesktopBackground.ToString()                                   $ScriptInformation.Add(@{Data = "User Portal (Web Client)"; Value = "Disabled"; }) > $Null
                                }                           }
                            
                                $txt = "Session/Experience/Performance/Performance/Font smoothing"                           If($PubItem.AllowedOSes.Windows)
                                If($MSWord -or $PDF)    
                                {                           {
                                        $SettingsWordTable += @{                                   $ScriptInformation.Add(@{Data = "Windows"; Value = "Enabled"; }) > $Null
                                        Text = $txt;    
                                        Value = $Policy.ClientPolicy.Session.Performance.FontSmoothing.ToString();    
                                        }                           }
                                }                           Else
                                If($HTML)    
                                {                           {
                                        $rowdata += @(,(                                   $ScriptInformation.Add(@{Data = "Windows"; Value = "Disabled"; }) > $Null
                                        $txt,$htmlbold,    
                                        $Policy.ClientPolicy.Session.Performance.FontSmoothing.ToString(),$htmlwhite))    
                                }                           }
                                If($Text)                          
                            If($PubItem.AllowedOSes.Wyse)
                                {                           {
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.FontSmoothing.ToString()                                   $ScriptInformation.Add(@{Data = "Wyse"; Value = "Enabled"; }) > $Null
                                }                           }
                            Else
                                $txt = "Session/Experience/Performance/Performance/Menu and window animation"    
                                If($MSWord -or $PDF)    
                                {                           {
                                        $SettingsWordTable += @{                                   $ScriptInformation.Add(@{Data = "Wyse"; Value = "Disabled"; }) > $Null
                                        Text = $txt;    
                                        Value = $Policy.ClientPolicy.Session.Performance.WindowMenuAnimation.ToString();    
                                        }                           }
                            
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitContent;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
     
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.OSFilterReplicate.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                                }                   }
                                If($HTML)                  
                    If(!($PubItem.IPFilterEnabled))
                                {                   {
                                        $rowdata += @(,(                           WriteWordLine 0 0 "IP Address filtering not enabled"
                                        $txt,$htmlbold,                           WriteWordLine 0 0 ""
                                        $Policy.ClientPolicy.Session.Performance.WindowMenuAnimation.ToString(),$htmlwhite))    
                                }                   }
                                If($Text)                   Else
                                {                   {
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.WindowMenuAnimation.ToString()                           WriteWordLine 0 0 "IP Address filtering is enabled"
                                }                           WriteWordLine 0 0 ""
                            WriteWordLine 0 0 "Allow the following IPs:" -FontSize 9 -Italics $True
 
                                $txt = "Session/Experience/Performance/Performance/Desktop composition" <>                         If($PubItem.AllowedIP4s.Count -gt 0)
                                If($MSWord -or $PDF)    
                                {                           {
                                        $SettingsWordTable += @{    
                                        Text = $txt;    
                                        Value = $Policy.ClientPolicy.Session.Performance.DesktopComposition.ToString();                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                    $NameTable = @()
                                        }                                  
                                    ForEach($item in $PubItem.AllowedIP4s)
                                }                                   {
                                If($HTML)                                           If($item.From -eq $item.To)
                                {                                           {
                                        $rowdata += @(,(                                                   $NameTable += @{
                                        $txt,$htmlbold,                                                   IPv4From = $item.From;
                                        $Policy.ClientPolicy.Session.Performance.DesktopComposition.ToString(),$htmlwhite))                                                   IPv4To   = ""
                                }                                                   }
                                If($Text)    
                                {    
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.DesktopComposition.ToString()    
                                }                                           }
                                            Else
                                <#$txt = "Session/Experience/Performance/Performance/Show contents of window while dragging"    
                                #This property is missing from $Policy.ClientPolicy.Session.Performance    
                                PS C:\Webster> $Policy.ClientPolicy.Session.Performance | fl *    
     
                                Enabled             : True    
                                NetType             : Satellite    
                                DesktopBackground   : True    
                                FontSmoothing       : True    
                                WindowMenuAnimation : True    
                                DesktopComposition  : True    
                                Themes              : True    
                                BitmapCaching       : True    
                                MoveSizeFullDrag    : True                                  
                                If($MSWord -or $PDF)    
                                {                                           {
                                        $SettingsWordTable += @{                                                   $NameTable += @{
                                        Text = $txt;                                                   IPv4From = $item.From;
                                        Value = $Policy.ClientPolicy.Session.Performance..ToString();                                                   IPv4To   = $item.To
                                        }                                                   }
                                }                                           }
                                If($HTML)    
                                {    
                                        $rowdata += @(,(    
                                        $txt,$htmlbold,    
                                        $Policy.ClientPolicy.Session.Performance..ToString(),$htmlwhite))    
 
                                If($Text) <>  
                                    If($NameTable.Count -gt 0)
 
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance..ToString() <>                                         $Table = AddWordTable -Hashtable $NameTable `
                                            -Columns IPv4From,IPv4To `
                                            -Headers "IPv4 Address From", "IPv4 Address To" `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitContent;
                                }#>    
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $txt = "Session/Experience/Performance/Performance/Themes" <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
                                If($MSWord -or $PDF)    
                                {    
                                        $SettingsWordTable += @{                                           FindWordDocumentEnd
                                        Text = $txt;                                           $Table = $Null
                                        Value = $Policy.ClientPolicy.Session.Performance.Themes.ToString();                                           WriteWordLine 0 0 ""
                                        }                                   }
                                }                           }
                                If($HTML)                          
                            If($PubItem.AllowedIP6s.Count -gt 0)
                                {                           {
                                        $rowdata += @(,(    
                                        $txt,$htmlbold,    
                                        $Policy.ClientPolicy.Session.Performance.Themes.ToString(),$htmlwhite))                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                    $NameTable = @()
                                }                                  
                                If($Text)                                   ForEach($item in $PubItem.AllowedIP6s)
 
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.Themes.ToString() <>                                         If($item.From -eq $item.To)
                                }    
     
                                $txt = "Session/Experience/Performance/Performance/Bitmap caching"    
                                If($MSWord -or $PDF)    
                                {                                           {
                                        $SettingsWordTable += @{                                                   $NameTable += @{
                                        Text = $txt;                                                   IPv6From = $item.From;
                                        Value = $Policy.ClientPolicy.Session.Performance.BitmapCaching.ToString();                                                   IPv6To   = ""
                                        }                                                   }
                                }                                           }
                                If($HTML)                                           Else
                                {                                           {
                                        $rowdata += @(,(                                                   $NameTable += @{
                                        $txt,$htmlbold,                                                   IPv6From = $item.From;
                                        $Policy.ClientPolicy.Session.Performance.BitmapCaching.ToString(),$htmlwhite))                                                   IPv6To   = $item.To
                                }                                                   }
                                If($Text)    
                                {    
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.BitmapCaching.ToString()    
                                }                                           }
                        }                                   }
 
                        $txt = "Session/Experience/Performance/Performance/Optimize resizing/moving windows" <>                                 If( $NameTable.Count -gt 0)
                        If($MSWord -or $PDF)    
                        {                                   {
                                            $Table = AddWordTable -Hashtable $NameTable `
                                            -Columns IPv6From,IPv6To `
                                            -Headers "IPv6 Address From", "IPv6 Address To" `
                                $SettingsWordTable += @{                                           -Format $wdTableGrid `
                                Text = $txt;                                           -AutoFit $wdAutoFitContent;
                                Value = $Policy.ClientPolicy.Session.Performance.MoveSizeFullDrag.ToString();    
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
 
                        If($HTML) <>  
                        {    
                                $rowdata += @(,(                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.Performance.MoveSizeFullDrag.ToString(),$htmlwhite))                           $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.IPFilterReplicate.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                        }                   }
                        If($Text)                  
                    If(!($PubItem.MACFilterEnabled))
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.MoveSizeFullDrag.ToString()                           WriteWordLine 0 0 "MAC filtering not enabled"
                            WriteWordLine 0 0 ""
                        }                   }
                }                   Else
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Experience/Compression"    
                If($Policy.ClientPolicy.Session.Compression.Enabled)    
 
                        $txt = "Session/Experience/Compression/Choose your compress preferences to optimize performance" <>                         WriteWordLine 0 0 "MAC filtering is enabled"
                        If($MSWord -or $PDF)                           WriteWordLine 0 0 ""
                            WriteWordLine 0 0 "Allow the following MACs:" -FontSize 9 -Italics $True
     
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $NameTable = @()
                            
                            ForEach($item in $PubItem.AllowedMACs)
 
                                $SettingsWordTable += @{ <>                                 $NameTable += @{
                                Text = $txt;                                   MAC = $item;
                                Value = $Policy.ClientPolicy.Session.Compression.Compress.ToString();    
 
                        If($HTML) <>  
                            If($NameTable.Count -gt 0)
 
                                $rowdata += @(,( <>                                 $Table = AddWordTable -Hashtable $NameTable `
                                $txt,$htmlbold,                                   -Columns MAC `
                                $Policy.ClientPolicy.Session.Compression.Compress.ToString(),$htmlwhite))                                   -Headers "MAC" `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitContent;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
 
                        If($Text) <>  
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Compression.Compress.ToString()                           $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.MACFilterReplicate.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                        }                   }
                    
                        $txt = "Session/Experience/Compression/Enable RDP compression"                   If(!($PubItem.GatewayFilterEnabled))
                        If($MSWord -or $PDF)    
                        {                   {
                                $SettingsWordTable += @{                           WriteWordLine 0 0 "Gateway filtering not enabled"
                                Text = $txt;                           WriteWordLine 0 0 ""
                                Value = $Policy.ClientPolicy.Session.Compression.Compress.ToString();    
                                }                   }
                        }                   Else
                        If($HTML)    
                        {                   {
                                $rowdata += @(,(                           WriteWordLine 0 0 "Gateway filtering is enabled"
                                $txt,$htmlbold,                           WriteWordLine 0 0 ""
                                $Policy.ClientPolicy.Session.Compression.Compress.ToString(),$htmlwhite))                           WriteWordLine 0 0 "Allow connections from the following Gateways:" -FontSize 9 -Italics $True
                        }    
                            $ScriptInformation = New-Object System.Collections.ArrayList
                        If($Text)                           $NameTable = @()
                            
                            ForEach($item in $PubItem.AllowedGateways)
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Compression.Compress.ToString() <>                                 $NameTable += @{
                                    GW = $item;
                        }                                   }
     
                        $PrintCompression = ""    
                        Switch($Policy.ClientPolicy.Session.Compression.PrintingCompression)    
                        {    
                                "CompressionDisabled"           {$PrintCompression = "Compression disabled"; Break}    
                                "BestSpeed"                                     {$PrintCompression = "Best speed (uses less CPU)"; Break}    
                                "BestSize"                                      {$PrintCompression = "Best size (uses less network traffic)"; Break}    
                                "BasedOnConnectionSpeed"        {$PrintCompression = "Based on connection speed"; Break}    
                                Default                                         {$PrintCompression = "Universal printing compression policy not found: $($Policy.ClientPolicy.Session.Compression.PrintingCompression)"; Break}    
 
                        $txt = "Session/Experience/Compression/Universal printing compression policy" <>                         If($NameTable.Count -gt 0)
                        If($MSWord -or $PDF)    
 
  <>                                 $Table = AddWordTable -Hashtable $NameTable `
                                    -Columns GW `
                                    -Headers "Gateways" `
                                $SettingsWordTable += @{                                   -Format $wdTableGrid `
                                Text = $txt;                                   -AutoFit $wdAutoFitContent;
                                Value = $PrintCompression;    
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
     
                                    WriteWordLine 0 0 ""
                                }                           }
                        }                   }
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $PrintCompression,$htmlwhite))    
                        }           }
                        If($Text)           If($OutputType -eq "Text")
                        {           {
                                OutputPolicySetting $txt $PrintCompression                   Line 2 "Filtering"
                    If(!($PubItem.UserFilterEnabled))
                    {
                            Line 3 "User filtering not enabled"
                            Line 0 ""
                        }                   }
                    Else
                    {
                        $ScanCompression = ""                           Line 3 "User filtering is enabled"
                        Switch($Policy.ClientPolicy.Session.Compression.ScanningCompression)                           Line 3 "Allow the following Users:"
                            Line 0 ""
                            
                            $maxLength = ($PubItem.AllowedUsers.Account | Measure-Object -Property length -Maximum).Maximum
                            $NegativeMaxLength = $maxLength * -1
                            Line 3 "User" -nonewline
                            Line 0 (" " * ($maxLength - 3)) -nonewline
                            LIne 0 "Type  SID"
                            Line 3 ("=" * ($maxLength + 1 + 6 + 45)) # $maxLength, space, "Type" plus 2 spaces, length of SID
                            ForEach($item in $PubItem.AllowedUsers)
 
                                "CompressionDisabled"           {$ScanCompression = "Compression disabled"; Break} <>                                 Line 3 ("{0,$NegativeMaxLength} {1,-5} {2,-45}" -f $item.Account,$item.Type,$item.Sid)
                                "BestSpeed"                                     {$ScanCompression = "Best speed (uses less CPU)"; Break}    
                                "BestSize"                                      {$ScanCompression = "Best size (uses less network traffic)"; Break}    
                                "BasedOnConnectionSpeed"        {$ScanCompression = "Based on connection speed"; Break}    
                                Default                                         {$ScanCompression = "Universal scanning compression policy not found: $($Policy.ClientPolicy.Session.Compression.ScanningCompression)"; Break}    
 
  -+                         Line 0 ""
 
                        $txt = "Session/Experience/Compression/Universal scanning compression policy" <>                         If(validObject $PubItem UserFilterReplicate)
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 Line 3 "Settings are replicated to all Sites: " $PubItem.UserFilterReplicate.ToString()
                                Text = $txt;                                   Line 0 ""
                                Value = $ScanCompression;    
                                }                           }
                        }                   }
                        If($HTML)                  
                    If(!($PubItem.ClientFilterEnabled))
                        {                   {
                                $rowdata += @(,(                           Line 3 "Client device name filtering not enabled"
                                $txt,$htmlbold,                           Line 0 ""
                                $ScanCompression,$htmlwhite))    
                        }                   }
                        If($Text)                   Else
                        {                   {
                            Line 3 "Client device name filtering is enabled"
                            Line 3 "Allow the following Clients:"
                            Line 0 ""
                            Line 3 "Client         "
                            Line 3 "==============="
                                OutputPolicySetting $txt $ScanCompression                           ForEach($item in $PubItem.AllowedClients)
                            {
                                    Line 3 ("{0,-15}" -f $item)
 
  -+                         Line 0 ""
     
                            Line 3 "Settings are replicated to all Sites: " $PubItem.ClientFilterReplicate.ToString()
                            Line 0 ""
 
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Network" <>                 If(!($PubItem.OSFilterEnabled))
                If($Policy.ClientPolicy.Session.Network.Enabled)    
 
                        If($Policy.ClientPolicy.Session.Network.UseProxyServer) <>                         Line 3 "Client device operating system filtering not enabled"
                            Line 0 ""
                    }
                    Else
                        {                   {
                                $txt = "Session/Network/Proxy settings/Use proxy server"                           Line 3 "Client device operating system filtering is enabled"
                            Line 3 "Allow access to clients running on the following operating system:"
                            Line 0 ""
                                $ProxyServer = ""                           Line 3 "Operating system"
                                Switch($Policy.ClientPolicy.Session.Network.ProxyType)                           Line 3 "================"
                            If($PubItem.AllowedOSes.Android)
                                {                           {
                                        0       {$ProxyServer = "SOCKS4"; Break}                                   Line 3 "Android`t`t: " "Enabled"
                                        1       {$ProxyServer = "SOCKS4A"; Break}    
                                        2       {$ProxyServer = "SOCKS5"; Break}    
                                        3       {$ProxyServer = "HTTP 1.1"; Break}    
                                        Default {$ProxyServer = "Use proxy server type not found: $($Policy.ClientPolicy.Session.Network.ProxyType)"; Break}    
                                }                           }
                                                          Else
                                If($MSWord -or $PDF)    
                                {                           {
                                        $SettingsWordTable += @{                                   Line 3 "Android`t`t: " "Disabled"
                                        Text = $txt;    
                                        Value = $ProxyServer;    
                                        }                           }
                                }                          
                                If($HTML)                           If($PubItem.AllowedOSes.Chrome)
                                {                           {
                                        $rowdata += @(,(                                   Line 3 "Chrome OS`t: " "Enabled"
                                        $txt,$htmlbold,    
                                        $ProxyServer,$htmlwhite))    
                                }                           }
                                If($Text)                           Else
                                {                           {
                                        OutputPolicySetting $txt $ProxyServer                                   Line 3 "Chrome OS`t: " "Disabled"
                                }                           }
                            
                                $txt = "Session/Network/Proxy settings/Proxy Host"                           If($PubItem.AllowedOSes.iOS)
                                If($MSWord -or $PDF)    
                                {                           {
                                        $SettingsWordTable += @{                                   Line 3 "iOS`t`t: " "Enabled"
                                        Text = $txt;    
                                        Value = $Policy.ClientPolicy.Session.Network.ProxyHost;    
                                        }                           }
                                }                           Else
                                If($HTML)    
                                {                           {
                                        $rowdata += @(,(                                   Line 3 "iOS`t`t: " "Disabled"
                                        $txt,$htmlbold,    
                                        $Policy.ClientPolicy.Session.Network.ProxyHost,$htmlwhite))    
                                }                           }
                                If($Text)                          
                            If($PubItem.AllowedOSes.Linux)
                                {                           {
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Network.ProxyHost                                   Line 3 "Linux`t`t: " "Enabled"
                                }                           }
                            Else
                                $txt = "Session/Network/Proxy settings/Port"    
                                If($MSWord -or $PDF)    
                                {                           {
                                        $SettingsWordTable += @{                                   Line 3 "Linux`t`t: " "Disabled"
                                        Text = $txt;    
                                        Value = $Policy.ClientPolicy.Session.Network.ProxyPort.ToString();    
                                        }                           }
                                }                          
                                If($HTML)                           If($PubItem.AllowedOSes.Mac)
                                {                           {
                                        $rowdata += @(,(                                   Line 3 "macOS`t`t: " "Enabled"
                                        $txt,$htmlbold,    
                                        $Policy.ClientPolicy.Session.Network.ProxyPort.ToString(),$htmlwhite))    
                                }                           }
                                If($Text)                           Else
                                {                           {
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Network.ProxyPort.ToString()                                   Line 3 "macOS`t`t: " "Disabled"
                                }                           }
                                                          
                                If($Policy.ClientPolicy.Session.Network.ProxyType -ge 2)                           If($PubItem.AllowedOSes.WebPortal)
                                {                           {
                                        $txt = "Session/Network/Proxy authentication/Proxy requires authentication"                                   Line 3 "RAS Web Portal`t: " "Enabled"
                                        If($MSWord -or $PDF)                           }
                            Else
                                        {                           {
                                                $SettingsWordTable += @{                                   Line 3 "RAS Web Portal`t: " "Disabled"
                                                Text = $txt;    
                                                Value = $Policy.ClientPolicy.Session.Network.ProxyAuthentication.ToString();    
                                                }                           }
                                        }                          
                                        If($HTML)                           If($PubItem.AllowedOSes.Windows)
                                        {                           {
                                                $rowdata += @(,(                                   Line 3 "Windows`t`t: " "Enabled"
                                                $txt,$htmlbold,    
                                                $Policy.ClientPolicy.Session.Network.ProxyAuthentication.ToString(),$htmlwhite))    
                                        }                           }
                                        If($Text)                           Else
                                        {                           {
                                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Network.ProxyAuthentication.ToString()                                   Line 3 "Windows`t`t: " "Disabled"
                                        }                           }
                                                                  
                                        If($Policy.ClientPolicy.Session.Network.ProxyAuthentication)                           If($PubItem.AllowedOSes.Wyse)
                                        {                           {
                                                $txt = "Session/Network/Proxy authentication/Use user logon credentials"                                   Line 3 "Wyse`t`t: " "Enabled"
                                                If($MSWord -or $PDF)                           }
                            Else
                                                {                           {
                                                        $SettingsWordTable += @{                                   Line 3 "Wyse`t`t: " "Disabled"
                                                        Text = $txt;    
                                                        Value = $Policy.ClientPolicy.Session.Network.ProxyUseLogonCredentials.ToString();    
                                                        }                           }
                            Line 0 ""
     
                            Line 3 "Settings are replicated to all Sites: " $PubItem.OSFilterReplicate.ToString()
                            Line 0 ""
                                                }                   }
                                                If($HTML)                  
                    If(!($PubItem.IPFilterEnabled))
                                                {                   {
                                                        $rowdata += @(,(                           Line 3 "IP Address filtering not enabled"
                                                        $txt,$htmlbold,                           Line 0 ""
                                                        $Policy.ClientPolicy.Session.Network.ProxyUseLogonCredentials.ToString(),$htmlwhite))    
                                                }                   }
                                                If($Text)                   Else
                                                {                   {
                                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Network.ProxyUseLogonCredentials.ToString()                           Line 3 "IP Address filtering is enabled"
                            Line 3 "Allow the following IPs:"
                                                }                           Line 0 ""
                                                                          
                                                If($Policy.ClientPolicy.Session.Network.ProxyUseLogonCredentials -eq $False)                           If($PubItem.AllowedIP4s.Count -gt 0)
                                                {                           {
                                                        $txt = "Session/Network/Proxy authentication/Username"                                   Line 3 "IPv4 Address From  IPv4 Address To"
                                                        If($MSWord -or $PDF)                                   Line 3 "=================================="
                                    #       255.255.255.255    255.255.255.255
                                    #       123456789012345SSSS123456789012345
                                    ForEach($item in $PubItem.AllowedIP4s)
                                                        {                                   {
                                                                $SettingsWordTable += @{                                           If($item.From -eq $item.To)
                                                                Text = $txt;    
                                                                Value = $Policy.ClientPolicy.Session.Network.ProxyUsername;    
                                                                }    
                                                        }    
                                                        If($HTML)    
                                                        {                                           {
                                                                $rowdata += @(,(                                                   Line 3 ("{0,-15}" -f $item.From)
                                                                $txt,$htmlbold,    
                                                                $Policy.ClientPolicy.Session.Network.ProxyUsername,$htmlwhite))    
                                                        }                                           }
                                                        If($Text)                                           Else
                                                        {                                           {
                                                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.Network.ProxyUsername                                                   Line 3 ("{0,-15}    {1,-15}" -f $item.From, $Item.To)
                                                        }                                           }
                                                }                                   }
                                        }                                  
                                }                                   Line 0 ""
 
                } <>  
                                          
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Server authentication"                           If($PubItem.AllowedIP6s.Count -gt 0)
                If($Policy.ClientPolicy.Session.ServerAuthentication.Enabled)    
                {                           {
                        $AuthFail = ""                                   $MaxFrom    = ($PubItem.AllowedIP6s.From | Measure-Object -Property length -maximum).Maximum
                        Switch($Policy.ClientPolicy.Session.ServerAuthentication.SessionAuthFailureAction)                                   $MaxTo      = ($PubItem.AllowedIP6s.To | Measure-Object -Property length -maximum).Maximum
                                    $NegMaxFrom = $MaxFrom * -1
                                    $NegMaxTo   = $MaxTo * -1
                                    
                                    $SpacesFrom = $MaxFrom - 17
                                    $SpacesTo   = $MaxTo - 15
                                    If($SpacesFrom -le 0)
                        {                                   {
                                "Connect"               {$AuthFail = "Connect"; Break}                                           $SpacesFrom = 17
                                "Warn"                  {$AuthFail = "Warn"; Break}    
                                "DoNotConnect"  {$AuthFail = "Do not connect"; Break}    
                                Default                 {$AuthFail = "RD session host authentication/If authentication fails not found: $($Policy.ClientPolicy.Session.ServerAuthentication.SessionAuthFailureAction)"; Break}    
                        }                                   }
                                    If($SpacesTo -le 0)
                        $txt = "Session/Server authentication/RD session host authentication/If authentication fails"    
                        If($MSWord -or $PDF)    
                        {                                   {
                                $SettingsWordTable += @{                                           $SpacesTo = 15
                                Text = $txt;    
                                Value = $AuthFail;    
 
  <>                                 Line 3 "IPv6 Address From  " -nonewline
                                    Line 0 (" " * $SpacesFrom) -nonewline
                                    Line 0 "IPv6 Address To" -nonewline
                                    Line 0 (" " * $SpacesTo)
                                    Line 3 ("=" * (($MaxFrom + $MaxTo) + 2))
     
                                    ForEach($item in $PubItem.AllowedIP6s)
                        }                                   {
                        If($HTML)                                           If($item.From -eq $item.To)
                        {                                           {
                                $rowdata += @(,(                                                   Line 3 ("{0,$NegMaxFrom}" -f $item.From)
                                $txt,$htmlbold,    
                                $AuthFail,$htmlwhite))    
                        }                                           }
                        If($Text)                                           Else
                        {                                           {
                                OutputPolicySetting $txt $AuthFail                                                   Line 3 ("{0,$NegMaxFrom}  {1,$NegMaxTo}" -f $item.From, $Item.To)
                        }                                           }
                }                                   }
                                                  
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Advanced settings"    
                If($Policy.ClientPolicy.Session.AdvancedSettings.Enabled)    
                {                                   Line 0 ""
                        $txt = "Session/Advanced settings/Use client system colors"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.UseClientColors.ToString();    
                                }                           }
     
                            Line 3 "Settings are replicated to all Sites: " $PubItem.IPFilterReplicate.ToString()
                            Line 0 ""
                        }                   }
                        If($HTML)                  
                    If(!($PubItem.MACFilterEnabled))
                        {                   {
                                $rowdata += @(,(                           Line 3 "MAC filtering not enabled"
                                $txt,$htmlbold,                           Line 0 ""
                                $Policy.ClientPolicy.Session.AdvancedSettings.UseClientColors.ToString(),$htmlwhite))    
                        }                   }
                        If($Text)                   Else
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.UseClientColors.ToString()                           Line 3 "MAC filtering is enabled"
                        }                           Line 3 "Allow the following MACs:"
                            Line 0 ""
                        $txt = "Session/Advanced settings/Use client system settings (border size, fonts, etc)"                           Line 3 "MAC         "
                        If($MSWord -or $PDF)                           Line 3 "============"
                            #       123456789012
                            ForEach($item in $PubItem.AllowedMACs)
 
                                $SettingsWordTable += @{ <>                                 Line 3 ("{0,-12}" -f $item)
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.UseClientSettings.ToString();    
                                }                           }
                            Line 0 ""
     
                            Line 3 "Settings are replicated to all Sites: " $PubItem.MACFilterReplicate.ToString()
                            Line 0 ""
                        }                   }
                        If($HTML)                  
                    If(!($PubItem.GatewayFilterEnabled))
                        {                   {
                                $rowdata += @(,(                           Line 3 "Gateway filtering not enabled"
                                $txt,$htmlbold,                           Line 0 ""
                                $Policy.ClientPolicy.Session.AdvancedSettings.UseClientSettings.ToString(),$htmlwhite))    
                        }                   }
                        If($Text)                   Else
                    {
                            Line 3 "Gateway filtering is enabled"
                            Line 3 "Allow connections from the following Gateways:"
                            Line 0 ""
                            Line 3 "Gateways       "
                            Line 3 "==============="
                            #       123456789012345
                            ForEach($item in $PubItem.AllowedGateways)
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.UseClientSettings.ToString() <>                                 Line 3 ("{0,-15}" -f $item)
 
  <>                         Line 0 ""
                        $txt = "Session/Advanced settings/Create shortcuts configured on server"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.CreateShrtCut.ToString();    
                                }                   }
                        }           }
                        If($HTML)           If($OutputType -eq "HTML")
                        {           {
                                $rowdata += @(,(                   WriteHTMLLine 3 0 "Filtering"
                                $txt,$htmlbold,                   If(!($PubItem.UserFilterEnabled))
                                $Policy.ClientPolicy.Session.AdvancedSettings.CreateShrtCut.ToString(),$htmlwhite))    
                        }    
                        If($Text)    
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.CreateShrtCut.ToString()                           WriteHTMLLine 0 0 "User filtering not enabled"
                            WriteHTMLLine 0 0 ""
                        }                   }
                    Else
                        $txt = "Session/Advanced settings/Register file extensions associated from the server"    
                        If($MSWord -or $PDF)    
                        {                   {
                                $SettingsWordTable += @{                           WriteHTMLLine 0 0 "User filtering is enabled"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.RegisterExt.ToString();    
                                }    
                            $rowdata = @()
                        }                          
                        If($HTML)                           ForEach($item in $PubItem.AllowedUsers)
 
                                $txt,$htmlbold, <>                                 $item.Account,$htmlwhite,
                                $Policy.ClientPolicy.Session.AdvancedSettings.RegisterExt.ToString(),$htmlwhite))                                   $item.Type,$htmlwhite,
                                    $item.Sid,$htmlwhite))
 
                        If($Text) <>  
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.RegisterExt.ToString()                           $columnHeaders = @(
                            "User",($Script:htmlsb),
                            "Type",($Script:htmlsb),
                            "SID",($Script:htmlsb))
                        }    
                            $msg = "Allow the following Users:"
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders
                            WriteHTMLLine 0 0 ""
 
                        $txt = "Session/Advanced settings/Redirect URLs to the client device" <>                         If(validObject $PubItem UserFilterReplicate)
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $rowdata = @()
                                Text = $txt;                                   $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.UserFilterReplicate.ToString(),$htmlwhite)
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.UrlRedirection.ToString();    
                                    $msg = ""
                                    $columnWidths = @("183","100")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                                }                           }
                        }                   }
                        If($HTML)                  
                    If(!($PubItem.ClientFilterEnabled))
                        {                   {
                                $rowdata += @(,(                           WriteHTMLLine 0 0 "Client device name filtering not enabled"
                                $txt,$htmlbold,                           WriteHTMLLine 0 0 ""
                                $Policy.ClientPolicy.Session.AdvancedSettings.UrlRedirection.ToString(),$htmlwhite))    
                        }                   }
                        If($Text)                   Else
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.UrlRedirection.ToString()                           WriteHTMLLine 0 0 "Client device name filtering is enabled"
                        }    
                            $rowdata = @()
                            
                        $txt = "Session/Advanced settings/Redirect MAILTO to the client device"                           ForEach($item in $PubItem.AllowedClients)
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $rowdata += @(,(
                                Text = $txt;                                   $item,$htmlwhite))
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.MailRedirection.ToString();    
                                }                           }
     
                            $columnHeaders = @(
                            "Client",($Script:htmlsb))
     
                            $msg = "Allow the following Clients:"
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders 
                            WriteHTMLLine 0 0 ""
     
                            $rowdata = @()
                            $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ClientFilterReplicate.ToString(),$htmlwhite)
     
                            $msg = ""
                            $columnWidths = @("183","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                        }                   }
                        If($HTML)                   If(!($PubItem.OSFilterEnabled))
                        {                   {
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.AdvancedSettings.MailRedirection.ToString(),$htmlwhite))                           WriteHTMLLine 0 0 "Client device operating system filtering not enabled"
                            WriteHTMLLine 0 0 ""
                        }                   }
                        If($Text)                   Else
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.MailRedirection.ToString()                           WriteHTMLLine 0 0 "Client device operating system filtering is enabled"
                        }                           $rowdata = @()
 
                        $txt = "Session/Advanced settings/Always ask for credentials when starting applications" <>                         If($PubItem.AllowedOSes.Android)
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $columnHeaders = @("Android",($Script:htmlsb),"Enabled",$htmlwhite)
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.CredAlwaysAsk.ToString();    
                                }                           }
                        }                           Else
                        If($HTML)    
 
                                $rowdata += @(,( <>                                 $columnHeaders = @("Android",($Script:htmlsb),"Disabled",$htmlwhite)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.AdvancedSettings.CredAlwaysAsk.ToString(),$htmlwhite))    
 
                        If($Text) <>                        
                            If($PubItem.AllowedOSes.Chrome)
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.CredAlwaysAsk.ToString() <>                                 $rowdata += @(,("Chrome OS",($Script:htmlsb),"Enabled",$htmlwhite))
 
  <>                         Else
                        $txt = "Session/Advanced settings/Allow server to send commands to be executed by client"    
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $rowdata += @(,("Chrome OS",($Script:htmlsb),"Disabled",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.AllowSrvCmd.ToString();    
                                }                           }
                        }                          
                        If($HTML)                           If($PubItem.AllowedOSes.iOS)
 
                                $rowdata += @(,( <>                                 $rowdata += @(,("iOS/iPadOS",($Script:htmlsb),"Enabled",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.AdvancedSettings.AllowSrvCmd.ToString(),$htmlwhite))    
 
                        If($Text) <>                         Else
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.AllowSrvCmd.ToString() <>                                 $rowdata += @(,("iOS/iPadOS",($Script:htmlsb),"Disabled",$htmlwhite))
 
  <>                         
                        $txt = "Session/Advanced settings/Confirm Server commands before executing them"                           If($PubItem.AllowedOSes.Linux)
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $rowdata += @(,("Linux",($Script:htmlsb),"Enabled",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.PromptSrvCmd.ToString();    
                                }                           }
                        }                           Else
                        If($HTML)    
 
                                $rowdata += @(,( <>                                 $rowdata += @(,("Linux",($Script:htmlsb),"Disabled",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.AdvancedSettings.PromptSrvCmd.ToString(),$htmlwhite))    
 
                        If($Text) <>                        
                            If($PubItem.AllowedOSes.Mac)
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.PromptSrvCmd.ToString() <>                                 $rowdata += @(,("macOS",($Script:htmlsb),"Enabled",$htmlwhite))
 
  <>                         Else
                        $txt = "Session/Advanced settings/Network Level Authentication"    
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $rowdata += @(,("macOS",($Script:htmlsb),"Disabled",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.CredSSP.ToString();    
                                }                           }
                        }                          
                        If($HTML)                           If($PubItem.AllowedOSes.WebPortal)
 
                                $rowdata += @(,( <>                                 $rowdata += @(,("User Portal (Web Client)",($Script:htmlsb),"Enabled",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.AdvancedSettings.CredSSP.ToString(),$htmlwhite))    
 
                        If($Text) <>                         Else
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.CredSSP.ToString() <>                                 $rowdata += @(,("User Portal (Web Client)",($Script:htmlsb),"Disabled",$htmlwhite))
 
  <>                         
                        $txt = "Session/Advanced settings/Redirect POS devices"                           If($PubItem.AllowedOSes.Windows)
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $rowdata += @(,("Windows",($Script:htmlsb),"Enabled",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.RedirPOS.ToString();    
                                }                           }
                        }                           Else
                        If($HTML)    
 
                                $rowdata += @(,( <>                                 $rowdata += @(,("Windows",($Script:htmlsb),"Disabled",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.AdvancedSettings.RedirPOS.ToString(),$htmlwhite))    
 
                        If($Text) <>                        
                            If($PubItem.AllowedOSes.Wyse)
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.RedirPOS.ToString() <>                                 $rowdata += @(,("Wyse",($Script:htmlsb),"Enabled",$htmlwhite))
 
  <>                         Else
                        $txt = "Session/Advanced settings/Use Pre Windows 2000 login format"    
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $rowdata += @(,("Wyse",($Script:htmlsb),"Disabled",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.Pre2000Cred.ToString();    
                                }                           }
                            
                            $msg = "Allow access to clients running on the following operating system:"
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders 
                            WriteHTMLLine 0 0 ""
     
                            $rowdata = @()
                            $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.OSFilterReplicate.ToString(),$htmlwhite)
     
                            $msg = ""
                            $columnWidths = @("183","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                        }                   }
                        If($HTML)                  
                    If(!($PubItem.IPFilterEnabled))
                        {                   {
                                $rowdata += @(,(                           WriteHTMLLine 0 0 "IP Address filtering not enabled"
                                $txt,$htmlbold,                           WriteHTMLLine 0 0 ""
                                $Policy.ClientPolicy.Session.AdvancedSettings.Pre2000Cred.ToString(),$htmlwhite))    
                        }                   }
                        If($Text)                   Else
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.Pre2000Cred.ToString()                           WriteHTMLLine 0 0 "IP Address filtering is enabled"
                        }    
                            If($PubItem.AllowedIP4s.Count -gt 0)
                            {
                        $txt = "Session/Advanced settings/Disable RDP-UDP for gateway connections"                                   $rowdata = @()
                        If($MSWord -or $PDF)                                  
                                    ForEach($item in $PubItem.AllowedIP4s)
                        {                                   {
                                $SettingsWordTable += @{                                           If($item.From -eq $item.To)
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.DisableRUDP.ToString();    
                                }                                           {
                                                    $rowdata += @(,(
                                                    $item.From,$htmlwhite,
                                                    "",$htmlwhite))
                        }                                           }
                        If($HTML)                                           Else
                        {                                           {
                                $rowdata += @(,(                                                   $rowdata += @(,(
                                $txt,$htmlbold,                                                   $item.From,$htmlwhite,
                                $Policy.ClientPolicy.Session.AdvancedSettings.DisableRUDP.ToString(),$htmlwhite))                                                   $item.To,$htmlwhite))
                        }                                           }
                        If($Text)    
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.DisableRUDP.ToString()    
                        }                                   }
 
                        $txt = "Session/Advanced settings/Do not show drive redirection dialog" <>                                 $columnHeaders = @(
                        If($MSWord -or $PDF)                                   "IPv4 Address From",($Script:htmlsb),
                                    "IPv4 Address To",($Script:htmlsb))
     
                                    $msg = "Allow the following IPs:"
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders
                                    If($PubItem.AllowedIP6s.Count -gt 0)
                        {                                   {
                                $SettingsWordTable += @{                                           WriteHTMLLine 0 0 ""
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.AdvancedSettings.DoNotShowDriveRedirectionDlg.ToString();    
 
                        If($HTML) <>  
                            If($PubItem.AllowedIP6s.Count -gt 0)
 
  <>                                 $rowdata = @()
                                    
                                    ForEach($item in $PubItem.AllowedIP6s)
                                    {
                                            If($item.From -eq $item.To)
                                            {
                                $rowdata += @(,(                                                   $rowdata += @(,(
                                $txt,$htmlbold,                                                   $item.From,$htmlwhite,
                                $Policy.ClientPolicy.Session.AdvancedSettings.DoNotShowDriveRedirectionDlg.ToString(),$htmlwhite))                                                   "",$htmlwhite))
                        }                                           }
                        If($Text)                                           Else
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.DoNotShowDriveRedirectionDlg.ToString()                                                   $rowdata += @(,(
                                                    $item.From,$htmlwhite,
                                                    $item.To,$htmlwhite))
                        }                                           }
                }                                   }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options"                                   $columnHeaders = @(
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Connection"                                   "IPv6 Address From",($Script:htmlsb),
                If($Policy.ClientPolicy.ClientOptions.Connection.Enabled)                                   "IPv6 Address To",($Script:htmlsb))
                {    
                        $ConnBanner = ""                                   If($PubItem.AllowedIP4s.Count -gt 0)
                        Switch($Policy.ClientPolicy.ClientOptions.Connection.ConnectionBannerType)    
                        {                                   {
                                "SplashWindow"                  {$ConnBanner = "Splash Window"; Break}                                           $msg = ""
                                "TaskBarToastWindow"    {$ConnBanner = "Taskbar Toast Window"; Break}                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders
                                "None"                                  {$ConnBanner = "None"; Break}    
                                Default                                 {$ConnBanner = "Connection/Connection banner not found: $($Policy.ClientPolicy.ClientOptions.Connection.ConnectionBannerType)"; Break}    
                        }                                   }
                                    Else
                        $txt = "Client options/Connection/Connection/Connection banner"    
                        If($MSWord -or $PDF)    
                        {                                   {
                                $SettingsWordTable += @{                                           $msg = "Allow the following IPs:"
                                Text = $txt;                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders
                                Value = $ConnBanner;    
 
                        If($HTML) <>                         WriteHTMLLine 0 0 ""
                        {    
                                $rowdata += @(,(                           $rowdata = @()
                                $txt,$htmlbold,                           $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.IPFilterReplicate.ToString(),$htmlwhite)
                                $ConnBanner,$htmlwhite))    
                            $msg = ""
                            $columnWidths = @("183","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                        }                   }
                        If($Text)                  
                    If(!($PubItem.MACFilterEnabled))
                        {                   {
                                OutputPolicySetting $txt $ConnBanner                           WriteHTMLLine 0 0 "MAC filtering not enabled"
                            WriteHTMLLine 0 0 ""
                        }                   }
                                          Else
                        If($Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshFarms -eq $False)    
                        {                   {
                                $txt = "Client options/Connection/Connection/Automatically refresh connected RAS connections every (minutes)"                           WriteHTMLLine 0 0 "MAC filtering is enabled"
                                If($MSWord -or $PDF)                           WriteHTMLLine 0 0 "Allow the following MACs:"
     
                            $rowdata = @()
                            
                            ForEach($item in $PubItem.AllowedMACs)
                                {                           {
                                        $SettingsWordTable += @{                                   $rowdata += @(,(
                                        Text = $txt;                                   $item,$htmlwhite))
                                        Value = $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshFarms.ToString();    
                                        }                           }
                                }    
                            $columnHeaders = @(
                            "MAC",($Script:htmlsb))
                                If($HTML)    
                            $msg = ""
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders 
                            WriteHTMLLine 0 0 ""
                                {    
                                        $rowdata += @(,(                           $rowdata = @()
                                        $txt,$htmlbold,    
                                        $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshFarms.ToString(),$htmlwhite))                           $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.MACFilterReplicate.ToString(),$htmlwhite)
     
                            $msg = ""
                            $columnWidths = @("183","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                                }                   }
                                If($Text)                  
                    If(!($PubItem.GatewayFilterEnabled))
                                {                   {
                                        OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshFarms.ToString()                           WriteHTMLLine 0 0 "Gateway filtering not enabled"
                                }                           WriteHTMLLine 0 0 ""
                        }                   }
                        Else                   Else
                        {                   {
                                $txt = "Client options/Connection/Connection/Automatically refresh connected RAS connections every (minutes)"                           WriteHTMLLine 0 0 "Gateway filtering is enabled"
                                If($MSWord -or $PDF)                           WriteHTMLLine 0 0 "Allow connections from the following Gateways:"
                                {    
                                        $SettingsWordTable += @{                           $rowdata = @()
                                        Text = $txt;    
                                        Value = $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshTime_Mins.ToString();    
                                        }                          
                                }                           ForEach($item in $PubItem.AllowedGateways)
                                If($HTML)    
                                {                           {
                                        $rowdata += @(,(                                   $rowdata += @(,(
                                        $txt,$htmlbold,                                   $item,$htmlwhite))
                                        $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshTime_Mins.ToString(),$htmlwhite))    
                                }                           }
                                If($Text)    
                            $columnHeaders = @(
                            "Gateways",($Script:htmlsb))
                                {    
                                        OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshTime_Mins.ToString()                           $msg = ""
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders 
                            WriteHTMLLine 0 0 ""
                            
                            #there is no replication setting for Gateway filters
                                }                   }
                        }           }
                }   }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Logging"   Function OutputPubItemShortCuts
                If($Policy.ClientPolicy.ClientOptions.Logging.Enabled)    
                {   {
                        $txt = "Client options/Logging/Logging/Log level"           Param([object] $PubItem,
            [string] $OutputType,
            [string] $DefaultCreateShortcutOnDesktop,
            [string] $DefaultCreateShortcutInStartFolder,
            [string] $DefaultStartPath,
            [string] $DefaultCreateShortcutInStartUpFolder,
            [string] $DefaultReplicateShortcutSettings
            )
                        $LogLevel = ""          
                        Switch($Policy.ClientPolicy.ClientOptions.Logging.LogLevel)           If($OutputType -eq "MSWordPDF")
                        {           {
                                "Verbose"       {$LogLevel = "Verbose"; Break}                   WriteWordLine 3 0 "Shortcuts"
                                "4"                     {$LogLevel = "Extended"; Break}    
                                "5"                     {$LogLevel = "Verbose"; Break}    
                                "Standard"      {$LogLevel = "Standard"; Break}    
                                "Extended"      {$LogLevel = "Extended"; Break}    
                                Default         {$LogLevel = "Logging/Log level not found: $($Policy.ClientPolicy.ClientOptions.Logging.LogLevel)"; Break}    
                        }    
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    If($PubItem.InheritShortcutDefaultSettings)
                                           {
                        If($MSWord -or $PDF)                           $ScriptInformation.Add(@{Data = "Create shortcut on Desktop"; Value = $DefaultCreateShortcutOnDesktop; }) > $Null
                            $ScriptInformation.Add(@{Data = "Create shortcut in Start Folder"; Value = $DefaultCreateShortcutInStartFolder; }) > $Null
                            If($DefaultCreateShortcutInStartFolder)
 
                                $SettingsWordTable += @{ <>                                 $ScriptInformation.Add(@{Data = ""; Value = $DefaultStartPath; }) > $Null
                                Text = $txt;    
                                Value = $LogLevel;    
                                }                           }
                            $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = $DefaultCreateShortcutInStartUpFolder; }) > $Null
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $DefaultReplicateShortcutSettings.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitContent;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                        }                   }
                        If($HTML)                   Else
                    {
                            $ScriptInformation.Add(@{Data = "Create shortcut on Desktop"; Value = $PubItem.CreateShortcutOnDesktop; }) > $Null
                            $ScriptInformation.Add(@{Data = "Create shortcut in Start Folder"; Value = $PubItem.CreateShortcutInStartFolder; }) > $Null
                            If($PubItem.CreateShortcutInStartFolder)
 
                                $rowdata += @(,( <>                                 $ScriptInformation.Add(@{Data = ""; Value = $PubItem.StartPath; }) > $Null
                                $txt,$htmlbold,    
                                $LogLevel,$htmlwhite))    
 
  <>                         $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = $PubItem.CreateShortcutInStartUpFolder; }) > $Null
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateShortcutSettings.ToString(); }) > $Null
                        If($Text)    
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitContent;
                        {    
                                OutputPolicySetting $txt $LogLevel                           SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                        }                   }
                    WriteWordLine 0 0 ""
                                   }
                        If($Policy.ClientPolicy.ClientOptions.Logging.LogLevel -ne "Verbose")   #Verbose from PoSH equals Standard in the console - weird           If($OutputType -eq "Text")
                        {           {
                                $LoggingDate = $Policy.ClientPolicy.ClientOptions.Logging.LoggingStartDateTime    
                                $LogDate     = ($LoggingDate.ToUniversalTime()).ToShortDateString()    
                                $LogTime     = ($LoggingDate.ToUniversalTime()).ToLongTimeString()    
                                $LogDuration = ""                   Line 2 "Shortcuts"
                                    
                                Switch($Policy.ClientPolicy.ClientOptions.Logging.LoggingDuration)                   If($PubItem.InheritShortcutDefaultSettings)
                                {                   {
                                        3600    {$LogDuration = "1 hour"; Break}                           Line 3 "Create shortcut on Desktop`t`t`t`t: " $DefaultCreateShortcutOnDesktop
                                        10800   {$LogDuration = "3 hours"; Break}                           Line 3 "Create shortcut in Start Folder`t`t`t`t: " $DefaultCreateShortcutInStartFolder
                                        21600   {$LogDuration = "6 hours"; Break}                           If($DefaultCreateShortcutInStartFolder)
                                        43200   {$LogDuration = "12 hours"; Break}    
                                        86400   {$LogDuration = "1 day"; Break}    
                                        259200  {$LogDuration = "3 days"; Break}    
                                        Default {$LogDuration = " not found: $($Policy.ClientPolicy.ClientOptions.Logging.LoggingDuration)"; Break}    
                                }    
                            
                                $txt = "Client options/Logging/Logging/Date"    
                                If($MSWord -or $PDF)    
                                {                           {
                                        $SettingsWordTable += @{    
                                        Text = $txt;    
                                        Value = $LogDate;                                   Line 4 $DefaultStartPath
                                        }                           }
                            Line 3 "Create shortcut in Auto Start Folder`t`t`t: " $DefaultCreateShortcutInStartUpFolder
                            Line 3 "Settings are replicated to all Sites`t`t`t: " $DefaultReplicateShortcutSettings.ToString()
                                }                   }
                                If($HTML)                   Else
                                {                   {
                                        $rowdata += @(,(                           Line 3 "Create shortcut on Desktop`t`t`t`t: " $PubItem.CreateShortcutOnDesktop
                                        $txt,$htmlbold,                           Line 3 "Create shortcut in Start Folder`t`t`t`t: " $PubItem.CreateShortcutInStartFolder
                                        $LogDate,$htmlwhite))                           If($PubItem.CreateShortcutInStartFolder)
                                }    
                                If($Text)    
                                {                           {
                                        OutputPolicySetting $txt $LogDate                                   Line 4 $PubItem.StartPath
                                }                           }
                                                          Line 3 "Create shortcut in Auto Start Folder`t`t`t: " $PubItem.CreateShortcutInStartUpFolder
                                                          Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateShortcutSettings.ToString()
                                $txt = "Client options/Logging/Logging/Start"    
                                If($MSWord -or $PDF)    
                                {    
                                        $SettingsWordTable += @{    
                                        Text = $txt;    
                                        Value = $LogTime;    
                                        }                   }
                    Line 0 ""
                                }           }
                                If($HTML)           If($OutputType -eq "HTML")
                                {           {
                    WriteHTMLLine 3 0 "Shortcuts"
     
                                        $rowdata += @(,(                   $rowdata = @()
                                        $txt,$htmlbold,                   If($PubItem.InheritShortcutDefaultSettings)
                                        $LogTime,$htmlwhite))    
                                }    
                                If($Text)    
                                {                   {
                                        OutputPolicySetting $txt $LogTime                           $columnHeaders = @("Create shortcut on Desktop",($Script:htmlsb),$DefaultCreateShortcutOnDesktop.ToString(),$htmlwhite)
                                }                           $rowdata += @(,("Create shortcut in Start Folder",($Script:htmlsb),$DefaultCreateShortcutInStartFolder.ToString(),$htmlwhite))
                                                          If($DefaultCreateShortcutInStartFolder)
                                    
                                $txt = "Client options/Logging/Logging/Duration"    
                                If($MSWord -or $PDF)    
                                {                           {
                                        $SettingsWordTable += @{                                   $rowdata += @(,("",($Script:htmlsb),$DefaultStartPath,$htmlwhite))
                                        Text = $txt;    
                                        Value = $LogDuration;    
                                        }                           }
                            $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),$DefaultCreateShortcutInStartUpFolder.ToString(),$htmlwhite))
                            $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$DefaultReplicateShortcutSettings.ToString(),$htmlwhite))
     
                            $msg = ""
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders
                                }                   }
                                If($HTML)                   Else
                                {                   {
                                        $rowdata += @(,(                           $columnHeaders = @("Create shortcut on Desktop",($Script:htmlsb),$PubItem.CreateShortcutOnDesktop.ToString(),$htmlwhite)
                                        $txt,$htmlbold,                           $rowdata += @(,("Create shortcut in Start Folder",($Script:htmlsb),$PubItem.CreateShortcutInStartFolder.ToString(),$htmlwhite))
                                        $LogDuration,$htmlwhite))                           If($PubItem.CreateShortcutInStartFolder)
                                }    
                                If($Text)    
                                {                           {
                                        OutputPolicySetting $txt $LogDuration                                   $rowdata += @(,("",($Script:htmlsb),$PubItem.StartPath,$htmlwhite))
                                }                           }
                            $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),$PubItem.CreateShortcutInStartUpFolder.ToString(),$htmlwhite))
                            $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ReplicateShortcutSettings.ToString(),$htmlwhite))
     
                            $msg = ""
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders
                        }                   }
                    WriteHTMLLine 0 0 ""
                        $txt = "Client options/Logging/Logging/Allow view log"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Logging.AllowViewLog.ToString();    
                                }           }
                        }   }
    #endregion
                        If($HTML)    
    #region process universal printing
    Function ProcessUniversalPrinting
                        {   {
                                $rowdata += @(,(           Param([object]$Site)
                                $txt,$htmlbold,          
                                $Policy.ClientPolicy.ClientOptions.Logging.AllowViewLog.ToString(),$htmlwhite))           Write-Verbose "$(Get-Date -Format G): Processing Universal Printing"
                        }          
            OutputUniversalPrintingSectionPage
            
            Write-Verbose "$(Get-Date -Format G): `tProcessing Universal Printing"
            
            $RASPrinterSettings = Get-RASPrintingSettings -SiteId $Site.Id -EA 0 4>$Null
            
                        If($Text)           If(!($?))
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Logging.AllowViewLog.ToString()                   Write-Warning "
                        }                   `n
                    Unable to retrieve Universal Printing information
                    "
                        $txt = "Client options/Logging/Logging/Allow clear log"    
                        If($MSWord -or $PDF)                   If($MSWord -or $PDF)
                        {                   {
                                $SettingsWordTable += @{                           WriteWordLine 0 0 "Unable to retrieve Universal Printing information"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Logging.AllowClearLog.ToString();    
                                }                   }
                        }    
                        If($HTML)                   If($Text)
                        {                   {
                                $rowdata += @(,(                           Line 0 "Unable to retrieve Universal Printing information"
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Logging.AllowClearLog.ToString(),$htmlwhite))    
                        }                   }
                        If($Text)                   If($HTML)
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Logging.AllowClearLog.ToString()                           WriteHTMLLine 0 0 "Unable to retrieve Universal Printing information"
                        }                   }
                            
                }           }
                          ElseIf($? -and $null -eq $RASPrinterSettings)
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Update"    
                If($Policy.ClientPolicy.ClientOptions.Update.Enabled)    
                {           {
                        $txt = "Client options/Update/Update/Check for updates on startup"                   Write-Host "
                    No Universal Printing information was found
                    " -ForegroundColor White
                        If($MSWord -or $PDF)                   If($MSWord -or $PDF)
                        {                   {
                                $SettingsWordTable += @{                           WriteWordLine 0 0 "No Universal Printing information was found"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Update.CheckForUpdateOnLaunch.ToString();    
                                }                   }
                        }    
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Update.CheckForUpdateOnLaunch.ToString(),$htmlwhite))    
                        }    
                        If($Text)                   If($Text)
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Update.CheckForUpdateOnLaunch.ToString()                           Line 0 "No Universal Printing information was found"
                        }                   }
                    If($HTML)
                        $txt = "Client options/Update/Client version management/Parallels Client"    
                        If($MSWord -or $PDF)    
                        {                   {
                                $SettingsWordTable += @{                           WriteHTMLLine 0 0 "No Universal Printing information was found"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Update.UpdateClientXmlUrl;    
                                }                   }
                        }           }
                        If($HTML)           Else
                        {           {
                                $rowdata += @(,(                   $RDSObjects     = New-Object System.Collections.ArrayList
                                $txt,$htmlbold,                   $VDIHostObjects = New-Object System.Collections.ArrayList
                                $Policy.ClientPolicy.ClientOptions.Update.UpdateClientXmlUrl,$htmlwhite))    
                    $Printingobj = [PSCustomObject] @{
                            PrinterNamePattern = $RASPrinterSettings.PrinterNamePattern
                            ReplicateSettings  = $RASPrinterSettings.ReplicatePrinterPattern
                            PrinterRetention   = $RASPrinterSettings.PrinterRetention
                        }                   }
                    
                    $results = Get-RASRDS -SiteId $Site.Id -EA 0 4>$Null
                    
                        If($Text)                   If(!($?))
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Update.UpdateClientXmlUrl                           Write-Warning "
                            `n
                            Unable to retrieve RDS Printing information
                            "
                            $RDSobjects = [PSCustomObject] @{
                                    Server        = "None found"
                                    Type          = "N/A"
                                    PrintingState = "N/A"
 
  <>                 ElseIf($? -and $null -eq $results)
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/PC keyboard"    
                If($Policy.ClientPolicy.ClientOptions.PCKeyboard.Enabled)    
 
                        $txt = "Client options/PC keyboard/PC keyboard/Force use PC keyboard (if applicable)" <>  
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{                   Write-Host "
                                Text = $txt;                   No RDS Printing information was found
                                Value = $Policy.ClientPolicy.ClientOptions.PCKeyboard.ForcePCKeybd.ToString();                   " -ForegroundColor White
                            $RDSobjects = [PSCustomObject] @{
                                    Server        = "None found"
                                    Type          = "N/A"
                                    PrintingState = "N/A"
                                }                           }
                        }                   }
                        If($HTML)                   Else
                        {                   {
                                $rowdata += @(,(                           ForEach($Result in $Results)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.PCKeyboard.ForcePCKeybd.ToString(),$htmlwhite))    
                        }    
                        If($Text)    
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.PCKeyboard.ForcePCKeybd.ToString() <>                                 If($Result.EnablePrinting)
                        }    
     
                        $KBLayout = ""    
                        Switch($Policy.ClientPolicy.ClientOptions.PCKeyboard.PCKeybd)    
                        {                                   {
                                "ChineseSimplified"             {$KBLayout = "Chinese (Simplified)"     ; Break}                                           $State = "Enabled"
                                "ChineseTraditional"    {$KBLayout = "Chinese (Traditional)"; Break}    
                                "Dutch"                                 {$KBLayout = "Dutch"                            ; Break}    
                                "EnglishUK"                             {$KBLayout = "English (UK)"                     ; Break}    
                                "EnglishUS"                             {$KBLayout = "English (US)"                     ; Break}    
                                "French"                                {$KBLayout = "French"                       ; Break}    
                                "FrenchCanada"                  {$KBLayout = "French (Canada)"          ; Break}    
                                "German"                                {$KBLayout = "German"                       ; Break}    
                                "Italian"                               {$KBLayout = "Italian"                      ; Break}    
                                "Japanese"                              {$KBLayout = "Japanese"                     ; Break}    
                                "Korean"                                {$KBLayout = "Korean"                       ; Break}    
                                "Maltese"                               {$KBLayout = "Maltese"                      ; Break}    
                                "NorwegianNynorsk"              {$KBLayout = "Norwegian (Nynorsk)"      ; Break}    
                                "PortugueseBrazil"              {$KBLayout = "Portuguese (Brazil)"      ; Break}    
                                "Portuguese"                    {$KBLayout = "Portuguese"                   ; Break}    
                                "Russian"                               {$KBLayout = "Russian"                      ; Break}    
                                "Spanish"                               {$KBLayout = "Spanish"                      ; Break}    
                                "Swedish"                               {$KBLayout = "Swedish"                      ; Break}    
                                Default                                 {$KBLayout = "PC keyboard/Keyboard layout not found: $($Policy.ClientPolicy.ClientOptions.PCKeyboard.PCKeybd)"; Break}    
                        }                                   }
                                    Else
                        $txt = "Client options/PC keyboard/PC keyboard/Keyboard layout"    
                        If($MSWord -or $PDF)    
                        {                                   {
                                $SettingsWordTable += @{                                           $State = "Disabled"
                                Text = $txt;    
                                Value = $KBLayout;    
 
  <>                                 
                                    $RDSobj = [PSCustomObject] @{
                                            Server        = $Result.Server
                                            Type          = "RD Session Hosts"
                                            PrintingState = $State
                        }                                   }
                        If($HTML)                                   $Null = $RDSObjects.Add($RDSobj)
                        {                   }
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $KBLayout,$htmlwhite))    
                        }                   }
                    
                    $results = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null
                    
                        If($Text)                   If(!($?))
                        {                   {
                                OutputPolicySetting $txt $KBLayout                           Write-Warning "
                            `n
                            Unable to retrieve VDI Hosts Printing information
                            "
                            
                            $VDIHostobjects = [PSCustomObject] @{
                                    Server        = "Unable to retrieve"
                                    Type          = "N/A"
                                    PrintingState = "N/A"
 
                <>                 ElseIf($? -and $null -eq $results)
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Single Sign-On"    
                If($Policy.ClientPolicy.ClientOptions.SingleSignOn.Enabled)    
 
                        $txt = "Client options/Single Sign-On/Single sign-on/Force to wrap third party SSO component" <>  
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{                   Write-Host "
                                Text = $txt;                   No VDI Hosts Printing information was found
                                Value = $Policy.ClientPolicy.ClientOptions.SingleSignOn.ForceThirdPartySSO.ToString();                   " -ForegroundColor White
                            $VDIHostobjects = [PSCustomObject] @{
                                    Server        = "None found"
                                    Type          = "N/A"
                                    PrintingState = "N/A"
                                }                           }
                        }                   }
                        If($HTML)                   Else
                        {                   {
                                $rowdata += @(,(                           ForEach($Result in $Results)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.SingleSignOn.ForceThirdPartySSO.ToString(),$htmlwhite))    
                        }                           {
                        If($Text)                                   If($Result.EnablePrinting)
                        {                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.SingleSignOn.ForceThirdPartySSO.ToString()                                           $State = "Enabled"
                        }                                   }
                                    Else
                        $txt = "Client options/Single Sign-On/Single sign-on/Third-party credentials provider GUID"    
                        If($MSWord -or $PDF)    
                        {                                   {
                                $SettingsWordTable += @{                                           $State = "Disabled"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.SingleSignOn.SSOProvGUID;    
 
  <>                                 
                                    $VDIHostsobj = [PSCustomObject] @{
                                            Server        = $Result.Server
                                            Type          = "VDI Providers"
                                            PrintingState = $State
                        }                                   }
                        If($HTML)                                   $Null = $VDIHostObjects.Add($VDIHostsobj)
                        {                           }
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.SingleSignOn.SSOProvGUID,$htmlwhite))    
                        }                   }
                        If($Text)    
                        {                  
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.SingleSignOn.SSOProvGUID                   OutputUniversalPrintingSettings $Printingobj $RDSobjects $VDIHostobjects
                    
                    OutputUniversalPrinterDriversSettings $RASPrinterSettings
                    
                    OutputUniversalPrinterFontsSettings $RASPrinterSettings
                        }           }
                }   }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced"   Function OutputUniversalPrintingSectionPage
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced/Global"    
                If($Policy.ClientPolicy.ClientOptions.Global.Enabled)    
                {   {
                        $txt = "Client options/Advanced/Global/Always on top"    
                        If($MSWord -or $PDF)           If($MSWord -or $PDF)
                        {           {
                                $SettingsWordTable += @{                   $Script:Selection.InsertNewPage()
                                Text = $txt;                   WriteWordLine 1 0 "Universal Printing"
                                Value = $Policy.ClientPolicy.ClientOptions.Global.AlwaysOnTop.ToString();    
                                }           }
                        }    
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Global.AlwaysOnTop.ToString(),$htmlwhite))    
                        }    
                        If($Text)           If($Text)
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.AlwaysOnTop.ToString()                   Line 0 "Universal Printing"
                        }           }
            If($HTML)
                        $txt = "Client options/Advanced/Global/Show connections tree"    
                        If($MSWord -or $PDF)    
                        {           {
                                $SettingsWordTable += @{                   WriteHTMLLine 1 0 "Universal Printing"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Global.ShowFolders.ToString();    
                                }           }
                        }   }
                        If($HTML)    
                        {    
                                $rowdata += @(,(   Function OutputUniversalPrintingSettings
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Global.ShowFolders.ToString(),$htmlwhite))    
                        }    
                        If($Text)    
                        {   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.ShowFolders.ToString()           Param([object]$Printingobj, [object]$RDSobj, [object]$VDIHostsobj)
                        }    
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Universal Printing"
            
                        $txt = "Client options/Advanced/Global/Minimize to tray on close or escape"    
                        If($MSWord -or $PDF)           If($MSWord -or $PDF)
                        {           {
                                $SettingsWordTable += @{                   WriteWordLine 2 0 "Universal Printing"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Global.MinimizeToTrayOnClose.ToString();    
                                }           }
                        }    
                        If($HTML)           If($Text)
                        {           {
                                $rowdata += @(,(                   Line 1 "Universal Printing"
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Global.MinimizeToTrayOnClose.ToString(),$htmlwhite))    
                        }           }
                        If($Text)           If($HTML)
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.MinimizeToTrayOnClose.ToString()                   WriteHTMLLine 2 0 "Universal Printing"
                        }           }
            
                        $txt = "Client options/Advanced/Global/Enable graphic accelerator (Chrome client)"    
                        If($MSWord -or $PDF)           If($MSWord -or $PDF)
                        {           {
                                $SettingsWordTable += @{                   WriteWordLine 3 0 "Options"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Global.GraphicsAccel.ToString();    
                                }           }
                        }    
                        If($HTML)           If($Text)
                        {           {
                                $rowdata += @(,(                   Line 2 "Options"
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Global.GraphicsAccel.ToString(),$htmlwhite))    
                        }           }
                        If($Text)           If($HTML)
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.GraphicsAccel.ToString()                   #Nothing
                        }           }
 
                        $txt = "Client options/Advanced/Global/Enable work area background (Chrome client)" <>  
                        If($MSWord -or $PDF)           If($MSWord -or $PDF)
                        {           {
                                $SettingsWordTable += @{                   $ScriptInformation = New-Object System.Collections.ArrayList
                                Text = $txt;                   $ScriptInformation.Add(@{Data = "Printer rename pattern"; Value = $Printingobj.PrinterNamePattern; }) > $Null
                                Value = $Policy.ClientPolicy.ClientOptions.Global.ClientWorkAreaBackground.ToString();                   $ScriptInformation.Add(@{Data = "Printer retention"; Value = $Printingobj.PrinterRetention; }) > $Null
                    $ScriptInformation.Add(@{Data = 'Settings are replicated to all Sites'; Value = $Printingobj.ReplicateSettings.ToString(); }) > $Null
                                }    
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                        }                   -List `
                        If($HTML)                   -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
                        {    
                                $rowdata += @(,(                   SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Global.ClientWorkAreaBackground.ToString(),$htmlwhite))                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 200;
                    $Table.Columns.Item(2).Width = 275;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
                        }           }
                        If($Text)           If($Text)
                        {           {
                    Line 3 "Printer rename pattern`t`t`t: " $Printingobj.PrinterNamePattern
                    Line 3 "Printer retention`t`t`t: " $Printingobj.PrinterRetention
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.ClientWorkAreaBackground.ToString()                   Line 3 "Settings are replicated to all Sites`t: " $Printingobj.ReplicateSettings.ToString()
                        }    
                    Line 0 ""
                        $txt = "Client options/Advanced/Global/Do not warn if server certificate is not verified"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Global.SSLNoWarning.ToString();    
                                }           }
                        }    
                        If($HTML)           If($HTML)
                        {           {
                    $rowdata = @()
                    $columnHeaders = @(
                            "Printer rename pattern",($Script:htmlsb),
                            $Printingobj.PrinterNamePattern,$htmlwhite
                    )
                                $rowdata += @(,(                   $rowdata += @(,(
                                $txt,$htmlbold,                           "Printer retention",($Script:htmlsb),
                                $Policy.ClientPolicy.ClientOptions.Global.SSLNoWarning.ToString(),$htmlwhite))                           $Printingobj.PrinterRetention.ToString(),$htmlwhite)
                        }                   )
                    $rowdata += @(,(
                            "Settings are replicated to all Sites",($Script:htmlsb),
                            $Printingobj.ReplicateSettings.ToString(),$htmlwhite)
                        If($Text)                   )
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.SSLNoWarning.ToString()                   $msg = "Options"
                    $columnWidths = @("200","300")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
                        }           }
            
                        $txt = "Client options/Advanced/Global/Swap mouse buttons"    
                        If($MSWord -or $PDF)           If($MSWord -or $PDF)
                        {           {
                                $SettingsWordTable += @{                   WriteWordLine 3 0 "Servers in site"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Global.SwapMouse.ToString();    
                                }           }
                        }    
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Global.SwapMouse.ToString(),$htmlwhite))    
                        }    
                        If($Text)           If($Text)
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.SwapMouse.ToString()                   Line 2 "Servers in site"
                        }           }
     
                        $txt = "Client options/Advanced/Global/DPI aware"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Global.DPIAware.ToString();    
                                }    
                        }    
                        If($HTML)           If($HTML)
                        {           {
                                $rowdata += @(,(                   #Nothing
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Global.DPIAware.ToString(),$htmlwhite))    
                        }           }
                        If($Text)    
            If($MSWord -or $PDF)
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.DPIAware.ToString()                   $ScriptInformation = New-Object System.Collections.ArrayList
                        }                   $ServersInSiteTable = @()
                    
                        $txt = "Client options/Advanced/Global/Add RAS connection automatically when starting web or shortcut items"                   ForEach($obj in $RDSobj)
                        If($MSWord -or $PDF)    
                        {                   {
                                $SettingsWordTable += @{                           $ServersInSiteTable += @{
                                Text = $txt;                                   Server = $obj.Server
                                Value = $Policy.ClientPolicy.ClientOptions.Global.AutoAddFarm.ToString();                                   Type   = $obj.Type
                                    State  = $obj.PrintingState
                                }                           }
                        }                   }
                        If($HTML)          
                    ForEach($obj in $VDIHostsobj)
                        {                   {
                                $rowdata += @(,(                           $ServersInSiteTable += @{
                                $txt,$htmlbold,                                   Server = $obj.Server
                                $Policy.ClientPolicy.ClientOptions.Global.AutoAddFarm.ToString(),$htmlwhite))                                   Type   = $obj.Type
                                    State  = $obj.PrintingState
 
                        If($Text) <>  
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.AutoAddFarm.ToString()    
                        }                   }
 
                        $txt = "Client options/Advanced/Global/Do not show prompt message for auto add RAS connection" <>                 If($ServersInSiteTable.Count -gt 0)
                        If($MSWord -or $PDF)    
                        {                   {
                            $Table = AddWordTable -Hashtable $ServersInSiteTable `
                            -Columns Server, Type, State `
                            -Headers "Server", "Type", "State" `
                                $SettingsWordTable += @{                           -Format $wdTableGrid `
                                Text = $txt;                           -AutoFit $wdAutoFitFixed;
     
                                Value = $Policy.ClientPolicy.ClientOptions.Global.DontPromptAutoAddFarm.ToString();                           SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
                            $Table.Columns.Item(3).Width = 100;
                            
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                                }                   }
                        }           }
                        If($HTML)           If($Text)
                        {           {
                                $rowdata += @(,(                   Line 3 "Server                         Type                 State   "
                                $txt,$htmlbold,                   Line 3 "============================================================"
                                $Policy.ClientPolicy.ClientOptions.Global.DontPromptAutoAddFarm.ToString(),$htmlwhite))                   #       123456789012345678901234567890S12345678901234567890S12345678
                        }    
                        If($Text)                   ForEach($obj in $RDSobj)
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.DontPromptAutoAddFarm.ToString()                           Line 3 ( "{0,-30} {1,-20} {2,-8}" -f
                                    $obj.Server, 
                                    $obj.Type, 
                                    $obj.PrintingState
                            )
                        }                   }
            
                        $txt = "Client options/Advanced/Global/Close error messages automatically"                   ForEach($obj in $VDIHostsobj)
                        If($MSWord -or $PDF)    
                        {                   {
                            Line 3 ( "{0,-30} {1,-20} {2,-8}" -f 
                                    $obj.Server, 
                                    $obj.Type, 
                                $SettingsWordTable += @{                                   $obj.PrintingState
                                Text = $txt;                           )
                                Value = $Policy.ClientPolicy.ClientOptions.Global.SuppErrMsgs.ToString();    
                                }                   }
     
                    Line 0 ""
                        }           }
                        If($HTML)           If($HTML)
                        {           {
                                $rowdata += @(,(                   $rowdata = @()
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Global.SuppErrMsgs.ToString(),$htmlwhite))    
                        }    
                        If($Text)                   ForEach($obj in $RDSobj)
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.SuppErrMsgs.ToString()                           $rowdata += @(,(
                        }                                   $obj.Server,$htmlwhite,
                                    $obj.Type,$htmlwhite,
                        $txt = "Client options/Advanced/Global/Clear session cookies on exit"                                   $obj.PrintingState,$htmlwhite)
                        If($MSWord -or $PDF)    
                        {                           )
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Global.ClearCookies.ToString();    
                                }                   }
                        }    
                        If($HTML)                   ForEach($obj in $VDIHostsobj)
                        {                   {
                                $rowdata += @(,(                           $rowdata += @(,(
                                    $obj.Server,$htmlwhite,
                                $txt,$htmlbold,                                   $obj.Type,$htmlwhite,
                                $Policy.ClientPolicy.ClientOptions.Global.ClearCookies.ToString(),$htmlwhite))                                   $obj.PrintingState,$htmlwhite)
                            )
                        }                   }
                    
                    $columnHeaders = @(
                            "Server",($Script:htmlsb),
                            "Type",($Script:htmlsb),
                            "State",($Script:htmlsb)
                        If($Text)                   )
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.ClearCookies.ToString()                   $msg = "Servers in site"
                    $columnWidths = @("200","100","100")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
                        }           }
                }   }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced/Language"   Function OutputUniversalPrinterDriversSettings
                If($Policy.ClientPolicy.ClientOptions.Language.Enabled)    
                {   {
                        $Lang = ""           Param([object] $RASPrinterSettings)
                        Switch($Policy.ClientPolicy.ClientOptions.Language.Lang)    
                        {    
                                "Default"                               {$Lang = "Default"                      ; Break}           Write-Verbose "$(Get-Date -Format G): `t`tOutput Printer drivers"
                                "English"                               {$Lang = "English"                      ; Break}    
                                "German"                                {$Lang = "German"                           ; Break}    
                                "Japanese"                              {$Lang = "Japanese"                         ; Break}    
                                "Russian"                               {$Lang = "Russian"                          ; Break}    
                                "French"                                {$Lang = "French"                           ; Break}    
                                "Spanish"                               {$Lang = "Spanish"                          ; Break}    
                                "Italian"                               {$Lang = "Italian"                          ; Break}    
                                "Portuguese"                    {$Lang = "Portuguese"               ; Break}    
                                "ChineseSimplified"             {$Lang = "Chinese (Simplified)" ; Break}    
                                "ChineseTraditional"    {$Lang = "Chinese (Traditional)"; Break}    
                                "Korean"                                {$Lang = "Korean"                           ; Break}    
                                "Dutch"                                 {$Lang = "Dutch"                                ; Break}    
                                Default                                 {$Lang = "Language/Advanced client options/Language not found: $($Policy.ClientPolicy.ClientOptions.PCKeyboard.PCKeybd)"; Break}    
                        }          
     
                        $txt = "Client options/Advanced/Language/Advanced client options/Language"    
                        If($MSWord -or $PDF)           If($MSWord -or $PDF)
                        {           {
                                $SettingsWordTable += @{                   WriteWordLine 2 0 "Printer drivers"
                                Text = $txt;    
                                Value = $Lang;    
                                }           }
            If($Text)
            {
                    Line 1 "Printer drivers"
                        }           }
                        If($HTML)           If($HTML)
                        {           {
                                $rowdata += @(,(                   WriteHTMLLine 2 0 "Printer drivers"
                                $txt,$htmlbold,    
                                $Lang,$htmlwhite))    
                        }           }
                        If($Text)    
            Switch ($RASPrinterSettings.DriverAllowMode)
                        {           {
                                OutputPolicySetting $txt $Lang                   "AllowRedirUsingAnyDriver"
                            {$RASPrinterSettingsDriverAllowMode = "Allow redirection of printers using any driver"; Break}
                    "AllowRedirUsingSpecifiedDriver"
                            {$RASPrinterSettingsDriverAllowMode = "Allow redirection of printers using one of the following drivers"; Break}
                    "DoNotAllowRedirUsingSpecifiedDriver"
                            {$RASPrinterSettingsDriverAllowMode = "Don't allow redirection of printers that use one of the following drivers"; Break}
                        }                   Default
                            {$RASPrinterSettingsDriverAllowMode = "Unable to determine RAS Printer Setting Driver Allow Mode: $($RASPrinterSettings.DriverAllowMode)"; Break}
                }           }
                          
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced/Printing"           If($RASPrinterSettingsDriverAllowMode -eq "Allow redirection of printers using any driver")
                If($Policy.ClientPolicy.ClientOptions.Printing.Enabled)    
                {           {
                        $txt = "Client options/Advanced/Printing/Install missing fonts automatically"    
                        If($MSWord -or $PDF)                   If($MSWord -or $PDF)
                        {                   {
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintInstallFonts.ToString();                           $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Mode"; Value = $RASPrinterSettingsDriverAllowMode; }) > $Null
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASPrinterSettings.ReplicatePrinterDrivers.ToString(); }) > $Null
                                }    
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
                        }    
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
                        If($HTML)    
                            $Table.Columns.Item(1).Width = 275;
                            $Table.Columns.Item(2).Width = 100;
                        {    
                                $rowdata += @(,(                           $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Printing.PrintInstallFonts.ToString(),$htmlwhite))                           FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                        }                   }
                        If($Text)                   If($Text)
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintInstallFonts.ToString()                           Line 2 "Mode: " $RASPrinterSettingsDriverAllowMode
                        }    
     
                        $txt = "Client options/Advanced/Printing/Redirect custom paper sizes when server preferences are selected"                           Line 2 "Settings are replicated to all Sites: " $RASPrinterSettings.ReplicatePrinterDrivers.ToString()
                        If($MSWord -or $PDF)    
                        {                           Line 0 ""
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintAddCustomPapers.ToString();    
                                }                   }
                        }    
                        If($HTML)                   If($HTML)
                        {                   {
                                $rowdata += @(,(                           $rowdata = @()
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Printing.PrintAddCustomPapers.ToString(),$htmlwhite))                           $columnHeaders = @("Mode",($Script:htmlsb),$RASPrinterSettingsDriverAllowMode,$htmlwhite)
                            $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASPrinterSettings.ReplicatePrinterDrivers.ToString(),$htmlwhite))
     
                            $msg = ""
                            $columnWidths = @("300","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                        }                   }
                        If($Text)           }
            Else
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintAddCustomPapers.ToString()                   $tmpArray = $RASPrinterSettings.PrinterDriversArray.Split(",")
                        }    
                    
                        $txt = "Client options/Advanced/Printing/Raw printing support"    
                        If($MSWord -or $PDF)                   If($MSWord -or $PDF)
                        {                   {
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintRawSupport.ToString();                           $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Mode"; Value = $RASPrinterSettingsDriverAllowMode; }) > $Null
                                }    
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
                        }    
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
                        If($HTML)    
                            $Table.Columns.Item(1).Width = 100;
                            $Table.Columns.Item(2).Width = 275;
                        {    
                                $rowdata += @(,(                           $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Printing.PrintRawSupport.ToString(),$htmlwhite))    
                        }    
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                        If($Text)    
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $DriverNameTable = @()
                            
                            ForEach($item in $tmpArray)
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintRawSupport.ToString() <>                                 $DriverNameTable += @{DriverName = $item}
 
                        $txt = "Client options/Advanced/Printing/Convert non distributable fonts data to images" <>                         If($DriverNameTable.Count -gt 0)
                        If($MSWord -or $PDF)    
 
  <>                                 $Table = AddWordTable -Hashtable $DriverNameTable `
                                    -Columns DriverName `
                                    -Headers "Driver name" `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                $SettingsWordTable += @{                                   $Table.Columns.Item(1).Width = 100;
                                Text = $txt;                                  
                                Value = $Policy.ClientPolicy.ClientOptions.Printing.AllowEMFRasterization.ToString();                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
                                }    
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
 
                        If($HTML) <>  
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASPrinterSettings.ReplicatePrinterDrivers.ToString(); }) > $Null
                        {    
                                $rowdata += @(,(                           $Table = AddWordTable -Hashtable $ScriptInformation `
                                $txt,$htmlbold,                           -Columns Data,Value `
                                $Policy.ClientPolicy.ClientOptions.Printing.AllowEMFRasterization.ToString(),$htmlwhite))                           -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                        }                   }
                        If($Text)                   If($Text)
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.AllowEMFRasterization.ToString()                           $maxLength = ($tmparray | Measure-Object -Property length -Maximum).Maximum
                            Line 2 "Mode: " $RASPrinterSettingsDriverAllowMode
                        }                           Line 0 ""
                            Line 2 "Driver name"
                            Line 2 ("=" * $maxLength)
                            
                        $txt = "Client options/Advanced/Printing/Cache printers hardware information"                           ForEach($item in $tmpArray)
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 Line 2 $item
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintUseCache.ToString();    
                                }                           }
                            Line 0 ""
                            Line 2 "Settings are replicated to all Sites: " $RASPrinterSettings.ReplicatePrinterDrivers.ToString()
                            Line 0 ""
                        }                   }
                        If($HTML)                   If($HTML)
                        {                   {
                                $rowdata += @(,(                           $rowdata = @()
                            $columnHeaders = @(
                                $txt,$htmlbold,                                   "Mode",($Script:htmlsb),
                                $Policy.ClientPolicy.ClientOptions.Printing.PrintUseCache.ToString(),$htmlwhite))                                   $RASPrinterSettingsDriverAllowMode,$htmlwhite
                        }                           )
                        If($Text)    
                            $msg = ""
                            $columnWidths = @("100","300")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                            
                            $rowdata = @()
     
                            ForEach($item in $tmpArray)
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintUseCache.ToString() <>                                 $rowdata += @(,($item,$htmlwhite))
 
  -+                         
                            $columnHeaders = @(
                                    "Driver name",($Script:htmlsb)
                            )
 
                        $txt = "Client options/Advanced/Printing/Refressh printer hardware information every 30 days" <>                         $msg = ""
                        If($MSWord -or $PDF)                           $columnWidths = @("100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                        {    
                                $SettingsWordTable += @{                           $rowdata = @()
                                Text = $txt;                           $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$RASPrinterSettings.ReplicatePrinterDrivers.ToString(),$htmlwhite)
                                Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintRefreshCache.ToString();    
                            $msg = ""
                            $columnWidths = @("183","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                                }                   }
                        }           }
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Printing.PrintRefreshCache.ToString(),$htmlwhite))    
                        }   }
                        If($Text)    
    Function OutputUniversalPrinterFontsSettings 
                        {   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintRefreshCache.ToString()           Param([object] $RASFontsSettings)
                        }    
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Fonts"
            
                        $txt = "Client options/Advanced/Printing/Cache RAS Universal Printing embedded fonts"    
                        If($MSWord -or $PDF)           If($MSWord -or $PDF)
                        {           {
                                $SettingsWordTable += @{                   WriteWordLine 2 0 "Fonts"
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintUseFontsCache.ToString();    
                                }           }
            If($Text)
            {
                    Line 1 "Fonts"
                        }           }
                        If($HTML)           If($HTML)
                        {           {
                                $rowdata += @(,(                   WriteHTMLLine 2 0 "Fonts"
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.Printing.PrintUseFontsCache.ToString(),$htmlwhite))    
                        }           }
                        If($Text)    
            If($RASFontsSettings.ExcludedFontsArray.Count -ne 0)
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintUseFontsCache.ToString()                   $tmpArray1 = $RASFontsSettings.ExcludedFontsArray.Split(",")
                        }                   $tmpArray1 = $tmpArray1 | Sort-Object
                    #$maxLength = ($tmparray1 | Measure-Object -Property length -Maximum).Maximum
                }           }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced/Windows client"    
                If($Policy.ClientPolicy.ClientOptions.WindowsClient.Enabled)    
                {           Else
                        $txt = "Client options/Advanced/Windows client/Advanced client options - Windows client/Hide Launcher when application is launched"    
                        If($MSWord -or $PDF)    
                        {           {
                                $SettingsWordTable += @{                   $tmpArray1 = @()
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.WindowsClient.Autohide.ToString();    
                                }           }
                        }    
                        If($HTML)           If($RASFontsSettings.AutoInstallFonts.Count -eq 0)
                        {           {
                                $rowdata += @(,(                   $tmpArray2 = @()
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.WindowsClient.Autohide.ToString(),$htmlwhite))    
                        }           }
                        If($Text)           Else
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.WindowsClient.Autohide.ToString()                   $tmpArray2 = $RASFontsSettings.AutoInstallFonts.Split(",")
                    $tmpArray2 = $tmpArray2 | Sort-Object
                    #$maxLength = ($tmparray2 | Measure-Object -Property length -Maximum).Maximum
                        }           }
 
                        $txt = "Client options/Advanced/Windows client/Advanced client options - Windows client/Launch automatically at Windows startup" <>  
                        If($MSWord -or $PDF)           If($MSWord -or $PDF)
                        {           {
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.WindowsClient.AutoLaunch.ToString();                   $ScriptInformation = New-Object System.Collections.ArrayList
                                }                   $ScriptInformation.Add(@{Data = "Transfer Fonts"; Value = $RASFontsSettings.EmbedFonts.ToString(); }) > $Null
                        }    
                        If($HTML)                   If($RASFontsSettings.EmbedFonts)
                        {                   {
                                $rowdata += @(,(                           If($tmpArray1.Count -ne 0)
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.WindowsClient.AutoLaunch.ToString(),$htmlwhite))    
                        }    
                        If($Text)    
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.WindowsClient.AutoLaunch.ToString() <>                                 $ScriptInformation.Add(@{Data = "     Exclude the following Fonts from embedding"; Value = ""; }) > $Null
                        }                                   $cnt = -1
                }                                   ForEach($item in $tmpArray1)
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced/RemoteFX USB redirection"    
                If($Policy.ClientPolicy.ClientOptions.RemoteFxUsbRedirection.Enabled)    
                {                                   {
                        $txt = "Client options/Advanced/RemoteFX USB redirection/RemoteFX USB redirection"                                           $cnt++
                        If($MSWord -or $PDF)                                          
                                            If($cnt -eq 0)
                        {                                           {
                                $SettingsWordTable += @{                                                   $ScriptInformation.Add(@{Data = "          Font name"; Value = $item; }) > $Null
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ClientOptions.RemoteFxUsbRedirection.RemoteFXUSBRedir.ToString();    
                                }                                           }
                        }                                           Else
                        If($HTML)    
                        {                                           {
                                $rowdata += @(,(                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ClientOptions.RemoteFxUsbRedirection.RemoteFXUSBRedir.ToString(),$htmlwhite))    
                        }                                           }
                        If($Text)    
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.RemoteFxUsbRedirection.RemoteFXUSBRedir.ToString()    
                        }                                   }
                }                           }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tControl settings"    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tControl settings/Connections"    
                If($Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.Enabled)    
                {                           Else
                        $txt = "Control settings/Connections/Connections/Prohibit adding of RAS connections"    
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 $ScriptInformation.Add(@{Data = "     Exclude the following Fonts from embedding"; Value = "None"; }) > $Null
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewASXGConns.ToString();    
                                }                           }
                        }                   }
                        If($HTML)    
                    If($tmpArray2.Count -eq 0)
                        {                   {
                                $rowdata += @(,(                           $ScriptInformation.Add(@{Data = "     Auto install fonts"; Value = "None"; }) > $Null
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewASXGConns.ToString(),$htmlwhite))    
                        }                   }
                    Else
                    {
                            $ScriptInformation.Add(@{Data = "     Auto install fonts"; Value = ""; }) > $Null
                            $cnt = -1
                            ForEach($item in $tmpArray2)
                            {
                                    $cnt++
                                    
                        If($Text)                                   If($cnt -eq 0)
                        {                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewASXGConns.ToString()                                           $ScriptInformation.Add(@{Data = "          Font file"; Value = $item; }) > $Null
                        }                                   }
                                    Else
                        $txt = "Control settings/Connections/Connections/Prohibit adding standard RDP connections"    
                        If($MSWord -or $PDF)    
                        {                                   {
                                $SettingsWordTable += @{                                           $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewStdConns.ToString();    
 
                        If($HTML) <>  
                        {                   }
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewStdConns.ToString(),$htmlwhite))                   $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASFontsSettings.ReplicatePrinterFont.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 220;
                    $Table.Columns.Item(2).Width = 200;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
                        }           }
                        If($Text)           If($Text)
                        {           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewStdConns.ToString()                   Line 2 "Transfer Fonts: " $RASFontsSettings.EmbedFonts.ToString()
                        }                   If($RASFontsSettings.EmbedFonts)
                }    
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tControl settings/Password"    
                If($Policy.ClientPolicy.ControlSettings.Password.Enabled)    
 
                        $txt = "Control settings/Password/Password/Prohibit saving password" <>                         If($tmpArray1.Count -ne 0)
                        If($MSWord -or $PDF)    
 
                                $SettingsWordTable += @{ <>                                 Line 3 "Exclude the following Fonts from embedding"
                                Text = $txt;                                   $cnt = -1
                                Value = $Policy.ClientPolicy.ControlSettings.Password.DontSavePwds.ToString();                                   ForEach($item in $tmpArray1)
                                }    
                        }    
                        If($HTML)    
                        {                                   {
                                $rowdata += @(,(                                           $cnt++
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ControlSettings.Password.DontSavePwds.ToString(),$htmlwhite))    
                        }                                           
                        If($Text)                                           If($cnt -eq 0)
                        {                                           {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ControlSettings.Password.DontSavePwds.ToString()                                                   Line 4 "Font name: " $item
                        }                                           }
                                            Else
                        $txt = "Control settings/Password/Password/Prohibit changing password"    
                        If($MSWord -or $PDF)    
                        {                                           {
                                $SettingsWordTable += @{                                                   Line 5 "   " $item
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.ControlSettings.Password.DontChangePwds.ToString();    
                                }                                           }
                        }                                   }
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ControlSettings.Password.DontChangePwds.ToString(),$htmlwhite))    
 
                        If($Text) <>                         Else
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.ControlSettings.Password.DontChangePwds.ToString() <>                                 Line 3 "Exclude the following Fonts from embedding" "None"
 
                 <>  
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tControl settings/Import and export"                   If($tmpArray2.Count -eq 0)
                If($Policy.ClientPolicy.ControlSettings.ImportExport.Enabled)    
 
                        $txt = "Control settings/Import and export/Import and export/Prohibit import/export connection settings" <>                         Line 3 "Auto install fonts" "None"
                        If($MSWord -or $PDF)                   }
                    Else
                        {                   {
                                $SettingsWordTable += @{                           Line 3 "Auto install fonts"
                                Text = $txt;                           $cnt = -1
                                Value = $Policy.ClientPolicy.ControlSettings.ImportExport.DontImportExport.ToString();                           ForEach($item in $tmpArray2)
                                }                           {
                                    $cnt++
                        }                                   
                        If($HTML)                                   If($cnt -eq 0)
                        {                                   {
                                $rowdata += @(,(                                           Line 4 "Font file: " $item
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.ControlSettings.ImportExport.DontImportExport.ToString(),$htmlwhite))    
                        }                                   }
                        If($Text)                                   Else
                        {                                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.ControlSettings.ImportExport.DontImportExport.ToString()                                           Line 5 "   " $item
                        }                                   }
                }                           }
                    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tRedirection"    
                If($Policy.ClientPolicy.Redirection.Enabled)    
                {    
                        $txt = "Redirection/New gateway/Gateway address"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Redirection.Gateway;    
                                }                   }
                    Line 2 "Settings are replicated to all Sites: " $RASFontsSettings.ReplicatePrinterFont.ToString()
                    Line 0 ""
                        }           }
                        If($HTML)           If($HTML)
                        {           {
                                $rowdata += @(,(                   $rowdata = @()
                                $txt,$htmlbold,                   $columnHeaders = @("Transfer Fonts",($Script:htmlsb),$RASFontsSettings.EmbedFonts.ToString(),$htmlwhite)
                                $Policy.ClientPolicy.Redirection.Gateway,$htmlwhite))    
                        }    
                        If($Text)                   If($RASFontsSettings.EmbedFonts)
                        {                   {
                                OutputPolicySetting $txt $Policy.ClientPolicy.Redirection.Gateway                           If($tmpArray1.Count -ne 0)
                        }    
     
                        $ConnMode = ""    
                        Switch($Policy.ClientPolicy.Redirection.Mode)    
 
                                "DirectMode"            {$ConnMode = "Direct Mode"; Break} <>                                 $rowdata += @(,("     Exclude the following Fonts from embedding",($Script:htmlsb),"",$htmlwhite))
                                "DirectSSLMode"         {$ConnMode = "Direct SSL Mode"; Break}    
                                "GatewayMode"           {$ConnMode = "Gateway Mode"; Break}    
                                "GatewaySSLMode"        {$ConnMode = "Gateway SSL Mode"; Break}    
                                Default                         {$ConnMode = "New gateway/Connection mode not found: $($Policy.ClientPolicy.Redirection.Mode)"; Break}    
                        }    
                                    $cnt = -1
                        $txt = "Redirection/New gateway/Connection mode"                                   ForEach($item in $tmpArray1)
                        If($MSWord -or $PDF)    
                        {                                   {
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $ConnMode;    
                                }                                           $cnt++
                        }                                           
                        If($HTML)                                           If($cnt -eq 0)
                        {                                           {
                                $rowdata += @(,(                                                   $rowdata += @(,("          Font name",($Script:htmlsb),$item,$htmlwhite))
                                $txt,$htmlbold,    
                                $ConnMode,$htmlwhite))    
                        }                                           }
                        If($Text)                                           Else
                        {                                           {
                                OutputPolicySetting $txt $ConnMode                                                   $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))
                        }                                           }
     
                        $txt = "Redirection/New gateway/Port"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Redirection.ServerPort.ToString();    
 
                        If($HTML) <>                         Else
 
                                $rowdata += @(,( <>                                 $rowdata += @(,("     Exclude the following Fonts from embedding",($Script:htmlsb),"None",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Redirection.ServerPort.ToString(),$htmlwhite))    
 
                        If($Text) <>  
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.Redirection.ServerPort.ToString()    
                        }                   }
 
                        $txt = "Redirection/New gateway/Alternative address" <>                 If($tmpArray2.Count -eq 0)
                        If($MSWord -or $PDF)    
                        {                   {
                                $SettingsWordTable += @{                           $rowdata += @(,("     Auto install fonts",($Script:htmlsb),"None",$htmlwhite))
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Redirection.AltGateway;    
                                }                   }
                        }                   Else
                        If($HTML)    
                        {                   {
                                $rowdata += @(,(                           $rowdata += @(,("     Auto install fonts",($Script:htmlsb),"",$htmlwhite))
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Redirection.AltGateway,$htmlwhite))    
                        }                           $cnt = -1
                        If($Text)                           ForEach($item in $tmpArray2)
 
                                OutputPolicySetting $txt $Policy.ClientPolicy.Redirection.AltGateway <>  
                        }                                   $cnt++
                }    
                                    
                If($MSWord -or $PDF)                                   If($cnt -eq 0)
                {                                   {
                        If($SettingsWordTable.Count -gt 0) #don't process if array is empty                                           $rowdata += @(,("          Font file",($Script:htmlsb),$item,$htmlwhite))
                        {    
                                WriteWordLine 4 0 "Properties"    
                                $Table = AddWordTable -Hashtable $SettingsWordTable `    
                                -Columns  Text,Value `    
                                -Headers  "Setting Key","Value"`    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 9 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 300;    
                                $Table.Columns.Item(2).Width = 200;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
                        }                                   }
                        Else                                   Else
                        {                                   {
                                WriteWordLine 0 1 "There are no policy properties"                                           $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))
                        }                                   }
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
                }                           }
                If($Text)    
                {    
                        Line 0 ""    
 
                If($HTML) <>                 $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASFontsSettings.ReplicatePrinterFont.ToString(),$htmlwhite))
                {    
                        If($rowdata.count -gt 0)    
                        {    
                                $columnHeaders = @(    
                                'Setting Key',($script:htmlsb),    
                                'Value',($script:htmlsb))    
 
                                $msg = "Properties" <>                 $msg = ""
                                $columnWidths = @("400","300")                   $columnWidths = @("260","220")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                   WriteHTMLLine 0 0 ""
                        }    
                }    
     
                Write-Verbose "$(Get-Date -Format G): "    
 
  +-  
Function OutputPolicySetting    
{    
        Param([string] $outputText, [string] $outputData)    
     
        If($outputText -ne "")    
        {    
                $xLength = $outputText.Length    
                If($outputText.Substring($xLength-2,2) -ne ": ")    
                {    
                        $outputText += ": "    
                }    
        }    
        Line 2 $outputText $outputData    
}    
 
#region process administration <> #region process universal scanning
Function ProcessAdministration   Function ProcessUniversalScanning
 
  <>         Param([object]$Site)
            
        Write-Verbose "$(Get-Date -Format G): Processing Administration"           Write-Verbose "$(Get-Date -Format G): Processing Universal scanning"
 
        OutputAdministrationSectionPage <>         OutputUniversalScanningSectionPage
 
        Write-Verbose "$(Get-Date -Format G): `tProcessing Accounts" <>         Write-Verbose "$(Get-Date -Format G): `tProcessing Universal Scanning"
 
        $results = Get-RASAdminAccount -EA 0 4>$Null <>         $results = Get-RASScanningSettings -SiteId $Site.Id -EA 0 4>$Null
 
                Unable to retrieve administration information <>                 Unable to retrieve Universal Scanning information
 
                        WriteWordLine 0 0 "Unable to retrieve administration information" <>                         WriteWordLine 0 0 "Unable to retrieve Universal Scanning information"
 
                        Line 0 "Unable to retrieve administration information" <>                         Line 0 "Unable to retrieve Universal Scanning information"
 
                        WriteHTMLLine 0 0 "Unable to retrieve administration information" <>                         WriteHTMLLine 0 0 "Unable to retrieve Universal Scanning information"
 
                No administration information was found <>                 No Universal Scanning information was found
 
                        WriteWordLine 0 0 "No administration information was found" <>                         WriteWordLine 0 0 "No Universal Scanning information was found"
 
                        Line 0 "No administration information was found" <>                         Line 0 "No Universal Scanning information was found"
 
                        WriteHTMLLine 0 0 "No administration information was found" <>                         WriteHTMLLine 0 0 "No Universal Scanning information was found"
 
                #make sure the results are sorted <>  
                $results = $results | Sort-Object Name                   $RDSObjects     = New-Object System.Collections.ArrayList
                    $VDIHostObjects = New-Object System.Collections.ArrayList
                    
                    $WIAobj = [PSCustomObject] @{
                            WIANamePattern    = $Results.WIANamePattern
                            ReplicateSettings = $Results.ReplicateWIAPattern
                    }
                    
                    $TWAINobj = [PSCustomObject] @{
                            TWAINNamePattern  = $Results.TWAINNamePattern
                            ReplicateSettings = $Results.ReplicateTWAINPattern
                    }
                    
                    $results = Get-RASRDS -SiteId $Site.Id -EA 0 4>$Null
                    
                    If(!($?))
                    {
                            Write-Warning "
                            `n
                            Unable to retrieve RDS Scanning information
                            "
                            $RDSobj = [PSCustomObject] @{
                                    Server = "Unable to retrieve"
                                    Type = "N/A"
                                    WIAState = "Disabled"
                                    TWAINState = "Disabled"
                            }
                            $Null = $RDSObjects.Add($RDSobj)
                    }
                    ElseIf($? -and $null -eq $results)
                    {
                    Write-Host "
                    No RDS Scanning information was found
                    " -ForegroundColor White
                            $RDSobj = [PSCustomObject] @{
                                    Server = "Not found"
                                    Type = "Not found"
                                    WIAState = "Disabled"
                                    TWAINState = "Disabled"
                            }
                            $Null = $RDSObjects.Add($RDSobj)
                    }
                    Else
                    {
                OutputRASAccounts $results                           ForEach($Result in $Results)
                            {
                                    If($Result.EnableWIA)
                                    {
                                            $WIAState = "Enabled"
                                    }
                                    Else
                                    {
                                            $WIAState = "Disabled"
                                    }
                                    
                                    If($Result.EnableTWAIN)
                                    {
                                            $TWAINState = "Enabled"
                                    }
                                    Else
                                    {
                                            $TWAINState = "Disabled"
                                    }
     
                                    $RDSobj = [PSCustomObject] @{
                                            Server = $Result.Server
                                            Type = "RD Session Hosts"
                                            WIAState = $WIAState
                                            TWAINState = $TwainState
                                    }
                                    $Null = $RDSObjects.Add($RDSobj)
                            }
                    }
                    
                    $results = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null
                    
                    If(!($?))
                    {
                            Write-Warning "
                            `n
                            Unable to retrieve VDI Hosts Scanning information
                            "
                            $VDIHostsobj = [PSCustomObject] @{
                                    Server = "Unable to retrieve"
                                    Type = "Unknown"
                                    WIAState = "Disabled"
                                    TWAINState = "Disabled"
                            }
                            $Null = $VDIHostObjects.Add($VDIHostsobj)
                    }
                    ElseIf($? -and $null -eq $results)
                    {
                    Write-Host "
                    No VDI Hosts Scanning information was found
                    " -ForegroundColor White
                            $VDIHostsobj = [PSCustomObject] @{
                                    Server = "None found"
                                    Type = "Unknown"
                                    WIAState = "Disabled"
                                    TWAINState = "Disabled"
                            }
                            $Null = $VDIHostObjects.Add($VDIHostsobj)
                    }
                    Else
                    {
                            ForEach($Result in $Results)
                            {
                                    If($Result.EnableWIA)
                                    {
                                            $WIAState = "Enabled"
                                    }
                                    Else
                                    {
                                            $WIAState = "Disabled"
                                    }
                                    
                                    If($Result.EnableTWAIN)
                                    {
                                            $TWAINState = "Enabled"
                                    }
                                    Else
                                    {
                                            $TWAINState = "Disabled"
                                    }
     
                                    $VDIHostsobj = [PSCustomObject] @{
                                            Server = $Result.Server
                                            Type = "VDI Providers"
                                            WIAState = $WIAState
                                            TWAINState = $TWAINState
                                    }
                                    $Null = $VDIHostObjects.Add($VDIHostsobj)
                            }
                    }
                    
                    OutputUniversalScanningSettings $WIAobj $TWAINobj $RDSobjects $VDIHostobjects
 
  -+ }
 
  <> Function OutputUniversalScanningSectionPage
    {
            If($MSWord -or $PDF)
            {
                    $Script:Selection.InsertNewPage()
                    WriteWordLine 1 0 "Universal Scanning"
            }
            If($Text)
            {
                    Line 0 "Universal Scanning"
            }
            If($HTML)
            {
                    WriteHTMLLine 1 0 "Universal Scanning"
            }
    }
     
    Function OutputUniversalScanningSettings
    {
     Param([object]$WIAobj, [object]$TWAINobj, [object]$RDSobj, [object]$VDIHostsobj)
     
            Write-Verbose "$(Get-Date -Format G): `t`tOutput WIA"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "WIA"
            }
            If($Text)
            {
                    Line 1 "WIA"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "WIA"
            }
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "Scanner rename"
            }
            If($Text)
            {
                    Line 2 "Scanner rename"
            }
            If($HTML)
            {
                    #Nothing
            }
     
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Pattern"; Value = $WIAObj.WIANamePattern; }) > $Null
                    $ScriptInformation.Add(@{Data = 'Settings are replicated to all Sites'; Value = $WIAObj.ReplicateSettings.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 200;
                    $Table.Columns.Item(2).Width = 275;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 3 "Pattern`t`t`t`t`t: " $WIAObj.WIANamePattern
                    Line 3 "Settings are replicated to all Sites`t: " $WIAObj.ReplicateSettings.ToString()
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @(
                            "Pattern",($Script:htmlsb),
                            $WIAObj.WIANamePattern,$htmlwhite
                    )
                    $rowdata += @(,(
                            "Settings are replicated to all Sites",($Script:htmlsb),
                            $WIAobj.ReplicateSettings.ToString(),$htmlwhite)
                    )
     
                    $msg = "Scanner rename"
                    $columnWidths = @("200","300")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "Servers in Site"
            }
            If($Text)
            {
                    Line 2 "Servers in Site"
            }
            If($HTML)
            {
                    #Nothing
            }
     
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ServersInSiteTable = @()
                    
                    ForEach($obj in $RDSObj)
                    {
                            $ServersInSiteTable += @{
                                    Server = $obj.Server
                                    Type   = $obj.Type
                                    State  = $obj.WIAState
                            }
                    }
                    
                    ForEach($obj in $VDIHostsobj)
                    {
                            $ServersInSiteTable += @{
                                    Server = $obj.Server
                                    Type   = $obj.Type
                                    State  = $obj.WIAState
                            }
                    }
     
                    If($ServersInSiteTable.Count -gt 0)
                    {
                            $Table = AddWordTable -Hashtable $ServersInSiteTable `
                            -Columns Server, Type, State `
                            -Headers "Server", "Type", "State" `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
                            $Table.Columns.Item(3).Width = 100;
                            
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                    }
            }
            If($Text)
            {
                    Line 3 "Server                         Type                 State   "
                    Line 3 "============================================================"
                    #       123456789012345678901234567890S12345678901234567890S12345678
     
                    ForEach($obj in $RDSobj)
                    {
                            Line 3 ( "{0,-30} {1,-20} {2,-8}" -f 
                                    $obj.Server, 
                                    $obj.Type, 
                                    $obj.WIAState
                            )
                    }
                    
                    ForEach($obj in $VDIHostsobj)
                    {
                            Line 3 ( "{0,-30} {1,-20} {2,-8}" -f 
                                    $obj.Server, 
                                    $obj.Type, 
                                    $obj.WIAState
                            )
                    }
     
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
     
                    ForEach($obj in $RDSobj)
                    {
                            $rowdata += @(,(
                                    $obj.Server,$htmlwhite,
                                    $obj.Type,$htmlwhite,
                                    $obj.WIAState,$htmlwhite)
                            )
                    }
            
                    ForEach($obj in $VDIHostsobj)
                    {
                            $rowdata += @(,(
                                    $obj.Server,$htmlwhite,
                                    $obj.Type,$htmlwhite,
                                    $obj.WIAState,$htmlwhite)
                            )
                    }
     
                    $columnHeaders = @(
                            "Server",($Script:htmlsb),
                            "Type",($Script:htmlsb),
                            "State",($Script:htmlsb)
                    )
     
                    $msg = "Servers in Site"
                    $columnWidths = @("200","100","100")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
     
            Write-Verbose "$(Get-Date -Format G): `t`tOutput TWAIN"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "TWAIN"
            }
            If($Text)
            {
                    Line 1 "TWAIN"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "TWAIN"
            }
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "Scanner rename"
            }
            If($Text)
            {
                    Line 2 "Scanner rename"
            }
            If($HTML)
            {
                    #Nothing
            }
     
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Pattern"; Value = $TWAINobj.TWAINNamePattern; }) > $Null
                    $ScriptInformation.Add(@{Data = 'Settings are replicated to all Sites'; Value = $TWAINobj.ReplicateSettings.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 200;
                    $Table.Columns.Item(2).Width = 275;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 3 "Pattern`t`t`t`t`t: " $TWAINobj.TWAINNamePattern
                    Line 3 "Settings are replicated to all Sites`t: " $TWAINobj.ReplicateSettings.ToString()
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @(
                            "Pattern",($Script:htmlsb),
                            $TWAINobj.TWAINNamePattern,$htmlwhite
                    )
                    $rowdata += @(,(
                            "Settings are replicated to all Sites",($Script:htmlsb),
                            $TWAINobj.ReplicateSettings.ToString(),$htmlwhite)
                    )
     
                    $msg = "Scanner rename"
                    $columnWidths = @("200","300")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "Servers in Site"
            }
            If($Text)
            {
                    Line 2 "Servers in Site"
            }
            If($HTML)
            {
                    #Nothing
            }
     
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ServersInSiteTable = @()
                    
                    ForEach($obj in $RDSobj)
                    {
                            $ServersInSiteTable += @{
                                    Server = $obj.Server
                                    Type   = $obj.Type
                                    State  = $obj.TwainState
                            }
                    }
                    
                    ForEach($obj in $VDIHostsobj)
                    {
                            $ServersInSiteTable += @{
                                    Server = $obj.Server
                                    Type   = $obj.Type
                                    State  = $obj.TwainState
                            }
                    }
     
                    If($ServersInSiteTable.Count -gt 0)
                    {
                            $Table = AddWordTable -Hashtable $ServersInSiteTable `
                            -Columns Server, Type, State `
                            -Headers "Server", "Type", "State" `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
                            $Table.Columns.Item(3).Width = 100;
                            
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                    }
            }
            If($Text)
            {
                    Line 3 "Server                         Type                 State   "
                    Line 3 "============================================================"
                    #       123456789012345678901234567890S12345678901234567890S12345678
     
                    ForEach($obj in $RDSobj)
                    {
                            Line 3 ( "{0,-30} {1,-20} {2,-8}" -f 
                                    $obj.Server, 
                                    $obj.Type, 
                                    $obj.TwainState
                            )
                    }
                    
                    ForEach($obj in $VDIHostsobj)
                    {
                            Line 3 ( "{0,-30} {1,-20} {2,-8}" -f 
                                    $obj.Server, 
                                    $obj.Type, 
                                    $obj.TwainState
                            )
                    }
     
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
     
                    ForEach($obj in $RDSobj)
                    {
                            $rowdata += @(,(
                                    $obj.Server,$htmlwhite,
                                    $obj.Type,$htmlwhite,
                                    $obj.TwainState,$htmlwhite)
                            )
                    }
                    
                    ForEach($obj in $VDIHostsobj)
                    {
                            $rowdata += @(,(
                                    $obj.Server,$htmlwhite,
                                    $obj.Type,$htmlwhite,
                                    $obj.TwainState,$htmlwhite)
                            )
                    }
                    
                    $columnHeaders = @(
                            "Server",($Script:htmlsb),
                            "Type",($Script:htmlsb),
                            "State",($Script:htmlsb)
                    )
     
                    $msg = "Servers in Site"
                    $columnWidths = @("200","100","100")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
    #endregion
     
    #region process connection
    Function ProcessConnection
    {
            Param([object]$Site)
            
            Write-Verbose "$(Get-Date -Format G): Processing Connection"
            
            OutputConnectionSectionPage
            
        Write-Verbose "$(Get-Date -Format G): `tProcessing Features"           Write-Verbose "$(Get-Date -Format G): `tProcessing Authentication"
 
        $RASFeatures = Get-RASSystemSettings -EA 0 4>$Null <>         $results = Get-RASAuthSettings -SiteId $Site.Id -EA 0 4>$Null
 
                Unable to retrieve features information <>                 Unable to retrieve authentication information
 
                        WriteWordLine 0 0 "Unable to retrieve features information" <>                         WriteWordLine 0 0 "Unable to retrieve authentication information"
 
                        Line 0 "Unable to retrieve features information" <>                         Line 0 "Unable to retrieve authentication information"
 
                        WriteHTMLLine 0 0 "Unable to retrieve features information" <>                         WriteHTMLLine 0 0 "Unable to retrieve authentication information"
 
        ElseIf($? -and $null -eq $RASFeatures) <>         ElseIf($? -and $null -eq $results)
 
                No features information was found <>                 No authentication information was found
 
                        WriteWordLine 0 0 "No features information was found" <>                         WriteWordLine 0 0 "No authentication information was found"
 
                        Line 0 "No features information was found" <>                         Line 0 "No authentication information was found"
 
                        WriteHTMLLine 0 0 "No features information was found" <>                         WriteHTMLLine 0 0 "No authentication information was found"
 
                OutputRASFeatures $RASFeatures <>  
                OutputRASSettings $RASFeatures                   OutputRASAuthSettings $results
 
  <>         Write-Verbose "$(Get-Date -Format G): `tProcessing Settings"
            
        $RASMailboxSettings = Get-RASMailboxSettings -EA 0 4>$Null           $results = Get-RASSessionSetting -SiteId $Site.Id -EA 0 4>$Null
 
                Unable to retrieve mailbox settings information <>                 Unable to retrieve RAS Session settings information
 
                        WriteWordLine 0 0 "Unable to retrieve mailbox settings information" <>                         WriteWordLine 0 0 "Unable to retrieve RAS Session settings information"
 
                        Line 0 "Unable to retrieve mailbox settings information" <>                         Line 0 "Unable to retrieve RAS Session settings information"
 
                        WriteHTMLLine 0 0 "Unable to retrieve mailbox settings information" <>                         WriteHTMLLine 0 0 "Unable to retrieve RAS Session settings information"
 
        ElseIf($? -and $null -eq $RASMailboxSettings) <>         ElseIf($? -and $null -eq $results)
 
                No mailbox settings information was found <>                 No RAS Session settings information was found
 
                        WriteWordLine 0 0 "No mailbox settings information was found" <>                         WriteWordLine 0 0 "No RAS Session settings information was found"
 
                        Line 0 "No mailbox settings information was found" <>                         Line 0 "No RAS Session settings information was found"
 
                        WriteHTMLLine 0 0 "No mailbox settings information was found" <>                         WriteHTMLLine 0 0 "No RAS Session settings information was found"
 
                OutputRASMailboxSettings $RASMailboxSettings <>                 OutputRASSessionSetting $results
 
  -+  
            Write-Verbose "$(Get-Date -Format G): `tProcessing Multi-Factor authentication"
 
        $RASReportingSettings = Get-RASReportingSettings -EA 0 4>$Null <>         $MFA = Get-RASMFA -SiteId $Site.Id -EA 0 4>$Null
 
                Unable to retrieve Reporting settings information <>                 Unable to retrieve Multi-Factor authentication information
 
                        WriteWordLine 0 0 "Unable to retrieve Reporting settings information" <>                         WriteWordLine 0 0 "Unable to retrieve Multi-Factor authentication information"
 
                        Line 0 "Unable to retrieve Reporting settings information" <>                         Line 0 "Unable to retrieve Multi-Factor authentication information"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Reporting settings information" <>                         WriteHTMLLine 0 0 "Unable to retrieve Multi-Factor authentication information"
 
        ElseIf($? -and $null -eq $RASReportingSettings) <>         ElseIf($? -and $null -eq $MFA)
 
                No Reporting settings information was found <>                 No Multi-Factor authentication information was found
 
                        WriteWordLine 0 0 "No Reporting settings information was found" <>                         WriteWordLine 0 0 "No Multi-Factor authentication information was found"
 
                        Line 0 "No Reporting settings information was found" <>                         Line 0 "No Multi-Factor authentication information was found"
 
                        WriteHTMLLine 0 0 "No Reporting settings information was found" <>                         WriteHTMLLine 0 0 "No Multi-Factor authentication information was found"
 
                OutputRASReportingSettings $RASReportingSettings <>                 OutputMFASetting $MFA
 
  <>         Write-Verbose "$(Get-Date -Format G): `tProcessing Allowed devices"
            
        $RASPerformanceMonitorSettings = Get-RASPerformanceMonitorSettings -EA 0 4>$Null           $results = Get-RASAllowedDevicesSetting -SiteId $Site.Id -EA 0 4>$Null
 
                Unable to retrieve Performance Monitor settings information <>                 Unable to retrieve Allowed devices information
 
                        WriteWordLine 0 0 "Unable to retrieve Performance Monitor settings information" <>                         WriteWordLine 0 0 "Unable to retrieve Allowed devices information"
 
                        Line 0 "Unable to retrieve Performance Monitor settings information" <>                         Line 0 "Unable to retrieve Allowed devices information"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Performance Monitor settings information" <>                         WriteHTMLLine 0 0 "Unable to retrieve Allowed devices information"
 
        ElseIf($? -and $null -eq $RASPerformanceMonitorSettings) <>         ElseIf($? -and $null -eq $results)
 
                No Performance Monitor settings information was found <>                 No Allowed devices information was found
 
                        WriteWordLine 0 0 "No Performance Monitor settings information was found" <>                         WriteWordLine 0 0 "No Allowed devices information was found"
 
                        Line 0 "No Performance Monitor settings information was found" <>                         Line 0 "No Allowed devices information was found"
 
                        WriteHTMLLine 0 0 "No Performance Monitor settings information was found" <>                         WriteHTMLLine 0 0 "No Allowed devices information was found"
 
                OutputRASPerformanceMonitorSettings $RASPerformanceMonitorSettings <>                 OutputRASAllowedDevicesSetting $results
 
Function OutputAdministrationSectionPage <> Function OutputConnectionSectionPage
 
                WriteWordLine 1 0 "Administration" <>                 WriteWordLine 1 0 "Connection"
 
                Line 0 "Administration" <>                 Line 0 "Connection"
 
                WriteHTMLLine 1 0 "Administration" <>                 WriteHTMLLine 1 0 "Connection"
 
Function OutputRASAccounts <> Function OutputRASAuthSettings
 
        Param([object] $RASAccounts) <>         Param([object] $RASAuthSettings)
 
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Accounts" <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput Authentication"
 
                WriteWordLine 2 0 "Accounts" <>                 WriteWordLine 2 0 "Authentication"
 
                Line 1 "Accounts" <>                 Line 1 "Authentication"
 
                WriteHTMLLine 2 0 "Accounts" <>                 WriteHTMLLine 2 0 "Authentication"
 
        ForEach($RASAccount in $RASAccounts) <>  
        {    
                Switch ($RASAccount.Permissions)           Switch ($RASAuthSettings.AuthType)
                {           {
                        "CustomAdmin"   {$RASAccountPermissions = "Custom administration"; Break}                   "UsernamePassword"                                      {$RASAuthSettingsAuthType = "Credentials"; Break}
                    "SmartCard"                                                     {$RASAuthSettingsAuthType = "Smart Card"; Break}
                        "PowerAdmin"    {$RASAccountPermissions = "Power administration"; Break}                   "UsernamePasswordOrSmartCard"           {$RASAuthSettingsAuthType = "Credentials, Smart Card"; Break}
                        "RootAdmin"             {$RASAccountPermissions = "Root administration"; Break}                   "Web"                                                           {$RASAuthSettingsAuthType = "Web (SAML)"; Break}
                        Default                 {$RASAccountPermissions = "Unable to determine Permissions: $($RASAccount.Permissions)"; Break}                   "UsernamePassword, Web"                         {$RASAuthSettingsAuthType = "Credentials, Web (SAML)"; Break}
                    "SmartCard, Web"                                        {$RASAuthSettingsAuthType = "Smart Card, Web (SAML)"; Break}
                    "UsernamePasswordOrSmartCard, Web"      {$RASAuthSettingsAuthType = "Credentials, Smart Card, Web (SAML)"; Break}
                    Default                                                         {$RASAuthSettingsAuthType = "Unable to determine AuthType: $($RASAuthSettings.AuthType)"; Break}
                }           }
            
                Switch ($RASAccount.Type)           If($MSWord -or $PDF)
                {           {
                        "Group"         {$RASAccountType = "Group"; Break}                   $ScriptInformation = New-Object System.Collections.ArrayList
                        "User"          {$RASAccountType = "User"; Break}    
                        "UserGroup"     {$RASAccountType = "Group User"; Break}    
                        Default         {$RASAccountType = "Unknown: $($RASAccount.Type)"; Break}                   $ScriptInformation.Add(@{Data = "Allowed authentication types"; Value = $RASAuthSettingsAuthType; }) > $Null
                }    
     
                Switch ($RASAccount.Notify)                   If($RASAuthSettings.AllTrustedDomains)
 
                        "Email"         {$RASAccountNotify = "Via email"; Break} <>                         $ScriptInformation.Add(@{Data = "Authentication domain"; Value = "All Trusted Domains"; }) > $Null
                        "None"          {$RASAccountNotify = "Don't receive"; Break}    
                        Default         {$RASAccountNotify = "Unknown: $($RASAccount.Notify)"; Break}    
 
  <>                 Else
                If($MSWord -or $PDF)    
 
                        $ScriptInformation = New-Object System.Collections.ArrayList <>  
                        $ScriptInformation.Add(@{Data = "Group or user names"; Value = $RASAccount.Name; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Type"; Value = $RASAccountType; }) > $Null    
                        $ScriptInformation.Add(@{Data = 'Permissions'; Value = $RASAccountPermissions; }) > $Null    
                        $ScriptInformation.Add(@{Data = 'Receive system notifications'; Value = $RASAccountNotify; }) > $Null    
                        $ScriptInformation.Add(@{Data = 'Email'; Value = $RASAccount.Email; }) > $Null    
                        $ScriptInformation.Add(@{Data = 'Mobile'; Value = $RASAccount.Mobile; }) > $Null    
                        $ScriptInformation.Add(@{Data = 'Group'; Value = $RASAccount.GroupName; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RASAccount.AdminLastMod; }) > $Null                           $ScriptInformation.Add(@{Data = "Authentication domain"; Value = "Specific: $($RASAuthSettings.Domain)"; }) > $Null
                    }
                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $RASAccount.TimeLastMod.ToString(); }) > $Null                   $ScriptInformation.Add(@{Data = "Use client domain if specified"; Value = $RASAuthSettings.UseClientDomain.ToString(); }) > $Null
                        $ScriptInformation.Add(@{Data = "Created by"; Value = $RASAccount.AdminCreate; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Created on"; Value = $RASAccount.TimeCreate.ToString(); }) > $Null                   $ScriptInformation.Add(@{Data = 'Force clients to use NetBIOS credentials'; Value = $RASAuthSettings.ForceNetBIOSCreds.ToString(); }) > $Null
                        $ScriptInformation.Add(@{Data = "ID"; Value = $RASAccount.Id.ToString(); }) > $Null                   $ScriptInformation.Add(@{Data = 'Settings are replicated to all Sites'; Value = $RASAuthSettings.ReplicateSettings.ToString(); }) > $Null
 
                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                 $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                   -Columns Data,Value `
                        -List `                   -List `
                        -Format $wdTableGrid `                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 250; <>                 $Table.Columns.Item(1).Width = 250;
                        $Table.Columns.Item(2).Width = 250;                   $Table.Columns.Item(2).Width = 175;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                 FindWordDocumentEnd
                        $Table = $Null                   $Table = $Null
                        WriteWordLine 0 0 ""                   WriteWordLine 0 0 ""
                }           }
                If($Text)           If($Text)
                {           {
                        Line 2 "Group or user names`t`t: " $RASAccount.Name    
                        Line 2 "Type`t`t`t`t: " $RASAccountType    
                        Line 2 "Permissions`t`t`t: " $RASAccountPermissions    
                        Line 2 "Receive system notifications`t: " $RASAccountNotify                   Line 2 "Allowed authentication types`t`t`t: " $RASAuthSettingsAuthType
                    If($RASAuthSettings.AllTrustedDomains)
                    {
                            Line 2 "All Trusted Domains" ""
                    }
                    Else
                    {
                        Line 2 "Email`t`t`t`t: " $RASAccount.Email                           Line 2 "Domain`t`t`t`t`t`t: " $RASAuthSettings.Domain
                        Line 2 "Mobile`t`t`t`t: " $RASAccount.Mobile                   }
                        Line 2 "Group`t`t`t`t: " $RASAccount.GroupName    
                        Line 2 "Last modification by`t`t: " $RASAccount.AdminLastMod    
                        Line 2 "Modified on`t`t`t: " $RASAccount.TimeLastMod.ToString()                   Line 2 "Use client domain if specified`t`t`t: " $RASAuthSettings.UseClientDomain.ToString()
                        Line 2 "Created by`t`t`t: " $RASAccount.AdminCreate                   Line 2 "Force clients to use NetBIOS credentials`t: " $RASAuthSettings.ForceNetBIOSCreds.ToString()
                        Line 2 "Created on`t`t`t: " $RASAccount.TimeCreate.ToString()                   Line 2 "Settings are replicated to all Sites`t`t: " $RASAuthSettings.ReplicateSettings.ToString()
                        Line 2 "ID`t`t`t`t: " $RASAccount.Id.ToString()    
                        Line 0 ""                   Line 0 ""
                }           }
                If($HTML)           If($HTML)
                {           {
                        $rowdata = @()                   $rowdata = @()
                        $columnHeaders = @("Group or user names",($Script:htmlsb),$RASAccount.Name,$htmlwhite)                   $columnHeaders = @("Allowed authentication types",($Script:htmlsb),$RASAuthSettingsAuthType,$htmlwhite)
                        $rowdata += @(,("Type",($Script:htmlsb),$RASAccountType,$htmlwhite))                   If($RASAuthSettings.AllTrustedDomains)
                        $rowdata += @(,("Permissions",($Script:htmlsb),$RASAccountPermissions,$htmlwhite))                   {
                        $rowdata += @(,("Receive system notifications",($Script:htmlsb),$RASAccountNotify,$htmlwhite))    
                        $rowdata += @(,("Email",($Script:htmlsb),$RASAccount.Email,$htmlwhite))                           $rowdata += @(,("All Trusted Domains",($Script:htmlsb),"",$htmlwhite))
                        $rowdata += @(,("Mobile",($Script:htmlsb),$RASAccount.Mobile,$htmlwhite))                   }
                        $rowdata += @(,("Group",($Script:htmlsb),$RASAccount.GroupName,$htmlwhite))                   Else
                    {
                        $rowdata += @(,("Last modification by",($Script:htmlsb), $RASAccount.AdminLastMod,$htmlwhite))                           $rowdata += @(,("Domain",($Script:htmlsb),$RASAuthSettings.Domain,$htmlwhite))
                    }
                        $rowdata += @(,("Modified on",($Script:htmlsb), $RASAccount.TimeLastMod.ToString(),$htmlwhite))                   $rowdata += @(,("Use client domain if specified",($Script:htmlsb),$RASAuthSettings.UseClientDomain.ToString(),$htmlwhite))
                        $rowdata += @(,("Created by",($Script:htmlsb), $RASAccount.AdminCreate,$htmlwhite))                   $rowdata += @(,("Force clients to use NetBIOS credentials",($Script:htmlsb),$RASAuthSettings.ForceNetBIOSCreds.ToString(),$htmlwhite))
                        $rowdata += @(,("Created on",($Script:htmlsb), $RASAccount.TimeCreate.ToString(),$htmlwhite))                   $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASAuthSettings.ReplicateSettings.ToString(),$htmlwhite))
                        $rowdata += @(,("ID",($Script:htmlsb),$RASAccount.Id.ToString(),$htmlwhite))    
 
                        $msg = "" <>                 $msg = ""
                        $columnWidths = @("200","175")                   $columnWidths = @("300","175")
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                        WriteHTMLLine 0 0 ""                   WriteHTMLLine 0 0 ""
                }    
 
Function OutputRASFeatures <> Function OutputRASSessionSetting
 
        Param([object] $RASFeatures) <>         Param([object] $RASSessionSettings)
 
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Features" <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput Settings"
 
                WriteWordLine 2 0 "Features" <>                 WriteWordLine 2 0 "Settings"
                WriteWordLine 3 0 "Helpdesk"    
 
                Line 1 "Features" <>                 Line 1 "Settings"
                Line 2 "Helpdesk"    
 
                WriteHTMLLine 2 0 "Features" <>                 WriteHTMLLine 2 0 "Settings"
                WriteHTMLLine 3 0 "Helpdesk"           }
            
            Switch ($RASSessionSettings.RemoteIdleSessionTimeout)
            {
                    60              {$RemoteIdleSessionTimeout = "1 minute"; Break}
                    180             {$RemoteIdleSessionTimeout = "3 minutes"; Break}
                    300             {$RemoteIdleSessionTimeout = "5 minutes"; Break}
                    600             {$RemoteIdleSessionTimeout = "10 minutes"; Break}
                    1800    {$RemoteIdleSessionTimeout = "30 minutes"; Break}
                    3600    {$RemoteIdleSessionTimeout = "1 hour"; Break}
                    5400    {$RemoteIdleSessionTimeout = "1 hour, 30 minutes"; Break}
                    7200    {$RemoteIdleSessionTimeout = "2 hours"; Break}
                    21600   {$RemoteIdleSessionTimeout = "6 hours"; Break}
                    43200   {$RemoteIdleSessionTimeout = "12 hours"; Break}
                    86400   {$RemoteIdleSessionTimeout = "1 day"; Break}
                    Default {$RemoteIdleSessionTimeout = "Unable to determine idle session timeout: $($RASSessionSettings.RemoteIdleSessionTimeout)"; Break}
 
  -+         Switch ($RASSessionSettings.LogoffIdleSessionTimeout)
            {
                    0               {$LogoffIdleSessionTimeout = "Never"; Break}
                    300             {$LogoffIdleSessionTimeout = "5 minutes"; Break}
                    600             {$LogoffIdleSessionTimeout = "10 minutes"; Break}
                    900             {$LogoffIdleSessionTimeout = "15 minutes"; Break}
                    1200    {$LogoffIdleSessionTimeout = "20 minutes"; Break}
                    1800    {$LogoffIdleSessionTimeout = "30 minutes"; Break}
                    3600    {$LogoffIdleSessionTimeout = "1 hour"; Break}
                    Default {$LogoffIdleSessionTimeout = "Unable to determine idle session logoff: $($RASSessionSettings.LogoffIdleSessionTimeout)"; Break}
            }
            
            Switch ($RASSessionSettings.CachedSessionTimeout)
            {
                    60              {$CachedSessionTimeout = "1 minute"; Break}
                    180             {$CachedSessionTimeout = "3 minutes"; Break}
                    300             {$CachedSessionTimeout = "5 minutes"; Break}
                    600             {$CachedSessionTimeout = "10 minutes"; Break}
                    1800    {$CachedSessionTimeout = "30 minutes"; Break}
                    3600    {$CachedSessionTimeout = "1 hour"; Break}
                    5400    {$CachedSessionTimeout = "1 hour, 30 minutes"; Break}
                    7200    {$CachedSessionTimeout = "2 hours"; Break}
                    21600   {$CachedSessionTimeout = "6 hours"; Break}
                    43200   {$CachedSessionTimeout = "12 hours"; Break}
                    86400   {$CachedSessionTimeout = "1 day"; Break}
                    86400   {$CachedSessionTimeout = "30 days"; Break}
                    Default {$CachedSessionTimeout = "Unable to determine cached session timeout: $($RASSessionSettings.CachedSessionTimeout)"; Break}
            }
            
 
                $ScriptInformation.Add(@{Data = "Enable Helpdesk functionality in Parallels Client"; Value = $RASFeatures.HelpDeskEnabled; }) > $Null <>                 $ScriptInformation.Add(@{Data = "Declare remote session idle after"; Value = $RemoteIdleSessionTimeout; }) > $Null
                $ScriptInformation.Add(@{Data = "Helpdesk email"; Value = $RASFeatures.HelpDeskEmail; }) > $Null                   $ScriptInformation.Add(@{Data = "Automatic logoff RAS idle session after"; Value = $LogoffIdleSessionTimeout; }) > $Null
                    $ScriptInformation.Add(@{Data = "Cached Session Timeout"; Value = $CachedSessionTimeout; }) > $Null
                    $ScriptInformation.Add(@{Data = 'FIPS 140-2 encryption'; Value = $RASSessionSettings.FIPSMode; }) > $Null
                    $ScriptInformation.Add(@{Data = 'Settings are replicated to all Sites'; Value = $RASSessionSettings.ReplicateSettings.ToString(); }) > $Null
 
                $Table.Columns.Item(2).Width = 250; <>                 $Table.Columns.Item(2).Width = 175;
 
                Line 3 "Enable Helpdesk functionality in Parallels Client`t: " $RASFeatures.HelpDeskEnabled <>                 Line 2 "Declare remote session idle after`t: " $RemoteIdleSessionTimeout
                Line 3 "Helpdesk email`t`t`t`t`t`t: " $RASFeatures.HelpDeskEmail                   Line 2 "Automatic logoff RAS idle session after`t: " $LogoffIdleSessionTimeout
                    Line 2 "Cached Session Timeout`t`t`t: " $CachedSessionTimeout
                    Line 2 "FIPS 140-2 encryption`t`t`t: " $RASSessionSettings.FIPSMode
                    Line 2 "Settings are replicated to all Sites`t: " $RASSessionSettings.ReplicateSettings.ToString()
 
                $columnHeaders = @("Enable Helpdesk functionality in Parallels Client",($Script:htmlsb),$RASFeatures.HelpDeskEnabled.ToString(),$htmlwhite) <>                 $columnHeaders = @("Declare remote session idle after",($Script:htmlsb),$RemoteIdleSessionTimeout,$htmlwhite)
                $rowdata += @(,("Helpdesk email",($Script:htmlsb),$RASFeatures.HelpDeskEmail,$htmlwhite))                   $rowdata += @(,("Automatic logoff RAS idle session after",($Script:htmlsb),$LogoffIdleSessionTimeout,$htmlwhite))
                    $rowdata += @(,("Cached Session Timeout",($Script:htmlsb),$CachedSessionTimeout,$htmlwhite))
                    $rowdata += @(,("FIPS 140-2 encryption",($Script:htmlsb),$RASSessionSettings.FIPSMode.ToString(),$htmlwhite))
                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASSessionSettings.ReplicateSettings.ToString(),$htmlwhite))
 
                $columnWidths = @("250","175") <>                 $columnWidths = @("300","175")
 
Function OutputRASSettings <> Function OutputMFASetting
 
        Param([object] $RASFeatures) <>         Param([object] $RASMFASettings)
 
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Settings" <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput Multi-Factor authentication"
 
                WriteWordLine 2 0 "Settings" <>                 WriteWordLine 2 0 "Multi-Factor authentication"
                WriteWordLine 3 0 "Customer experience program"    
 
                Line 1 "Settings" <>                 Line 1 "Multi-Factor authentication"
                Line 2 "Customer experience program"    
 
                WriteHTMLLine 2 0 "Settings" <>                 WriteHTMLLine 2 0 "Multi-Factor authentication"
                WriteHTMLLine 3 0 "Customer experience program"    
 
  <>  
            ForEach($RASMFASetting in $RASMFASettings)
                  {
                    Switch ($RASMFASetting.Type)
                    {
                            "None"                  {$RASMFASettingProvider = "None"; Break}
                            "Deepnet"               {$RASMFASettingProvider = "Deepnet"; Break}
                            "SafeNet"               {$RASMFASettingProvider = "SafeNet"; Break}
                            "Radius"                {$RASMFASettingProvider = "RADIUS"; Break}
                            "AzureRadius"   {$RASMFASettingProvider = "Azure MFA server (RADIUS)"; Break}
                            "DuoRadius"     {$RASMFASettingProvider = "Duo (RADIUS)"; Break}
                            "FortiRadius"   {$RASMFASettingProvider = "FortiAuthenticator (RADIUS)"; Break}
                            "TekRadius"     {$RASMFASettingProvider = "TekRADIUS"; Break}
                            "GAuthTOTP"             {$RASMFASettingProvider = "Google Authenticator"; Break}
                            Default                 {$RASMFASettingProvider = "Unable to determine MFA Provider: $($RASMFASetting.Type)"; Break}
                    }
     
        If($MSWord -or $PDF)                   If($MSWord -or $PDF)
        {                   {
                            WriteWordLine 3 0 "Provider settings"
                $ScriptInformation = New-Object System.Collections.ArrayList                           $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Provider"; Value = $RASMFASettingProvider; }) > $Null
                            
                            If($RASMFASettingProvider -ne "None")
                            {
                                    $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null
                                    
                                    If($RASMFASetting.Type -eq "AzureRadius")
                                    {
                                            $ScriptInformation.Add(@{Data = "     General"; Value = ""; }) > $Null
                $ScriptInformation.Add(@{Data = "Participate in the Customer Experience Program"; Value = $RASFeatures.CEPEnabled.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Enable MFA provider in site"; Value = $RASMFASetting.Enabled.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Name"; Value = $RASMFASetting.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Description"; Value = $RASMFASetting.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Type"; Value = $RASMFASetting.DisplayName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Display Name"; Value = $RASMFASetting.DisplayName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Timeout (seconds)"; Value = $RASMFASetting.Timeout; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.RadiusAttrName)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.VendorID)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                            $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Enable Action: $($Item.Enabled.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Description: $($Item.Description)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Action message: $($Item.ActionMessage)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                    }
                                    ElseIf($RASMFASetting.Type -eq "DuoRadius")
                                    {
                                            $ScriptInformation.Add(@{Data = "          Type"; Value = $RASMFASetting.DisplayName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Primary Server"; Value = $RASMFASetting.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Secondary Server"; Value = $RASMFASetting.BackupServer; }) > $Null
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                            $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                    }
                                    ElseIf($RASMFASetting.Type -eq "FortiRadius")
                                    {
                                            $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RASMFASetting.DisplayName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                            $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                    }
                                    ElseIf($RASMFASetting.Type -eq "TekRadius")
                                    {
                                            $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RASMFASetting.DisplayName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                            $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                    }
                                    ElseIf($RASMFASetting.Type -eq "Radius")
                                    {
                                            $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RASMFASetting.DisplayName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                            $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                    }
                                    ElseIf($RASMFASetting.Type -eq "Deepnet")
                                    {
                                            Switch($RASMFASetting.AuthMode)
                                            {
                                                    "MandatoryForAllUsers"                                          {$DeepNetAuthMode = "Mandatory for all users"; Break}
                                                    "CreateTokenForDomainAuthenticatedUsers"        {$DeepNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                                    "UsersWithSafeNetAcc"                                           {$DeepNetAuthMode = "Use only for users with a safe account"; Break}
                                                    Default                                                                         {$DeepNetAuthMode = "Deepnet mode not found: $($RASMFASetting.AuthMode)"; Break}
                                            }
                                            
                                            $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Type"; Value = $RASMFASetting.DeepnetType; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Server"; Value = $RASMFASetting.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Enable SSL"; Value = $RASMFASetting.SSL.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Agent"; Value = $RASMFASetting.DeepnetAgent; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Application"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Application"; Value = $RASMFASetting.App; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Domain"; Value = $RASMFASetting.DefaultDomain; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Mode"; Value = $DeepNetAuthMode; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Token Type"; Value = $RASMFASetting.TokenType.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Allow Channels"; Value = "Email: $($RASMFASetting.ActivateEmail.ToString())"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "                        "; Value = "SMS: $($RASMFASetting.ActivateSMS.ToString())"; }) > $Null
                                    }
                                    ElseIf($RASMFASetting.Type -eq "SafeNet")
                                    {
                                            Switch($RASMFASetting.AuthMode)
                                            {
                                                    "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}
                                                    "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                                    "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}
                                                    Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RASMFASetting.AuthMode)"; Break}
                                            }
 
  <>                                         $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          OTP Service URL"; Value = $RASMFASetting.OTPServiceURL; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Mode"; Value = $SafeNetAuthMode; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          TMS Web API URL"; Value = $RASMFASetting.TMSWebApiURL; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          User Repository"; Value = $RASMFASetting.UserRepository; }) > $Null
                                    }
                                    ElseIf($RASMFASetting.Type -eq "GAuthTOTP")
                                    {
                                            Switch($RASMFASetting.UserEnrollment)
                                            {
                                                    "Allow"                 {$GAuthAllow = "Allow"; Break}
                                                    "AllowUntil"    {$GAuthAllow = "Allow until"; Break}
                                                    "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}
                                                    Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RASMFASetting.UserEnrollment)"; Break}
                                            }
                                            
                                            Switch($RASMFASetting.Tolerance)
                                            {
                                                    0               {$TOTPTolerance = "None"; Break}
                                                    30              {$TOTPTolerance = "+/- 30 seconds"; Break}
                                                    60              {$TOTPTolerance = "+/- 60 seconds"; Break}
                                                    90              {$TOTPTolerance = "+/- 90 seconds"; Break}
                                                    120             {$TOTPTolerance = "+/- 120 seconds"; Break}
                                                    Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}
                                            }
                                            
                                            $ScriptInformation.Add(@{Data = "     Type Name"; Value = $RASMFASetting.Type; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     User Enrollment"; Value = ""; }) > $Null
                                            If($GAuthAllow -eq "Allow until")
                                            {
                                                    $GAuthFullDate = $RASMFASetting.UntilDateTime
                                                    $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()
                                                    $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()
                                                    $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = "Date: $GAuthDate"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Time: $GAuthTime"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = ""; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          TOTP tolerence"; Value = $TOTPTolerance; }) > $Null
                                    }
     
                                    <#If($RASMFASetting.RestrictionMode -eq "Exclusion")
                                    {
                                            $ScriptInformation.Add(@{Data = "Enable MFA for all users except"; Value = ""; }) > $Null
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = "Disable MFA for all users except"; Value = ""; }) > $Null
                                    }#>
                                    
                $Table = AddWordTable -Hashtable $ScriptInformation `                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 250;
                $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 175;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
        }    
        If($Text)    
        {    
                Line 3 "Participate in the Customer Experience Program`t`t: " $RASFeatures.CEPEnabled.ToString()    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @("Participate in the Customer Experience Program",($Script:htmlsb),$RASFeatures.CEPEnabled.ToString(),$htmlwhite)    
 
                $msg = "" <>  
                $columnWidths = @("200","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
     
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 3 0 "HTTP proxy settings"                                   <#WriteWordLine 3 0 "Restrictions"
        }    
        If($Text)    
        {    
                Line 2 "HTTP proxy settings"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 3 0 "HTTP proxy settings"    
        }    
            
        If($MSWord -or $PDF)    
        {    
                If($RASFeatures.HttpProxyMode -eq "NoProxy")    
                {    
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                        $ScriptInformation.Add(@{Data = "No proxy server"; Value = ""; }) > $Null    
     
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 250;    
                        $Table.Columns.Item(2).Width = 250;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
                }    
                Else    
                {    
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $ScriptInformation.Add(@{Data = "Manual HTTP proxy configuration"; Value = ""; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Address"; Value = $RASFeatures.HttpProxyAddress; }) > $Null    
                        $ScriptInformation.Add(@{Data = "Port"; Value = $RASFeatures.HttpProxyPort; }) > $Null    
                        $ScriptInformation.Add(@{Data = "User name"; Value = $RASFeatures.HttpProxyUser; }) > $Null                                   $ScriptInformation.Add(@{Data = "User or group list"; Value = $RASMFASetting.ExcludeUserGroup.ToString(); }) > $Null
                        $ScriptInformation.Add(@{Data = "Password"; Value = $RASFeatures.HttpProxyPwd; }) > $Null    
     
                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                        -Columns Data,Value `    
                        -List `    
                        -Format $wdTableGrid `    
                        -AutoFit $wdAutoFitFixed;    
     
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                        $Table.Columns.Item(1).Width = 250;    
                        $Table.Columns.Item(2).Width = 250;    
     
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                        FindWordDocumentEnd    
                        $Table = $Null    
                        WriteWordLine 0 0 ""    
                }    
        }    
        If($Text)    
        {    
                If($RASFeatures.HttpProxyMode -eq "NoProxy")                                   If($RASMFASetting.ExcludeUserGroup)
                {                                   {
                        Line 3 "No proxy server"                                           If($RASMFASetting.ExcludeUserGroupList.Count -gt 0)
                        Line 0 ""    
                }    
                Else    
                {                                           {
                        Line 3 "Manual HTTP proxy configuration"     
                        Line 3 "Address`t`t: " $RASFeatures.HttpProxyAddress    
                        Line 3 "Port`t`t: " $RASFeatures.HttpProxyPort    
                        Line 3 "User name`t: " $RASFeatures.HttpProxyUser                                                   ForEach($Item in $RASMFASetting.ExcludeUserGroupList)
                        Line 3 "Password`t: " $RASFeatures.HttpProxyPwd    
                        Line 0 ""    
                }    
        }    
        If($HTML)    
        {                                                   {
                If($RASFeatures.HttpProxyMode -eq "NoProxy")    
                {    
                        $rowdata = @()    
                        $columnHeaders = @("No proxy server",($Script:htmlsb),"",$htmlwhite)                                                           $ScriptInformation.Add(@{Data = ""; Value = "User: $($Item.Account)"; }) > $Null
     
                        $msg = ""    
                        $columnWidths = @("200","175")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }    
                Else    
                {    
                        $rowdata = @()    
                        $columnHeaders = @("Manual HTTP proxy configuration",($Script:htmlsb),"",$htmlwhite)                                                           $ScriptInformation.Add(@{Data = ""; Value = "Type: $($Item.Type)"; }) > $Null
                        $rowdata += @(,("Address",($Script:htmlsb),$RASFeatures.HttpProxyAddress,$htmlwhite))                                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                        $rowdata += @(,("Port",($Script:htmlsb),$RASFeatures.HttpProxyPort.ToString(),$htmlwhite))    
                        $rowdata += @(,("User name",($Script:htmlsb),$RASFeatures.HttpProxyUser,$htmlwhite))    
                        $rowdata += @(,("Password",($Script:htmlsb),$RASFeatures.HttpProxyPwd,$htmlwhite))    
     
                        $msg = ""    
                        $columnWidths = @("200","175")    
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                        WriteHTMLLine 0 0 ""    
                }                                                   }
        }                                           }
     
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 3 0 "Miscellaneous"    
        }                                   }
        If($Text)    
                                    $ScriptInformation.Add(@{Data = "Client IP list"; Value = $RASMFASetting.ExcludeClientIPs.ToString(); }) > $Null
                                    If($RASMFASetting.ExcludeClientIPs)
        {                                   {
                Line 2 "Miscellaneous"                                           If($RASMFASetting.ExcludeClientIPList.Count -gt 0)
        }    
        If($HTML)    
        {                                           {
                WriteHTMLLine 3 0 "Miscellaneous"    
        }                                                   $cnt     = -1
                                                    $MaxFrom = (($RASMFASetting.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                    $MaxTo   = (($RASMFASetting.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)
            
        Switch ($RASFeatures.ResetIdleSessionAfterMins)                                                   ForEach($Item in $RASMFASetting.ExcludeClientIPList)
        {                                                   {
                0               {$RASFeaturesResetIdleSessionAfterMins = "Never"; Break}    
                15              {$RASFeaturesResetIdleSessionAfterMins = "15 minutes"; Break}    
                30              {$RASFeaturesResetIdleSessionAfterMins = "30 minutes"; Break}    
                60              {$RASFeaturesResetIdleSessionAfterMins = "1 hour"; Break}    
                180             {$RASFeaturesResetIdleSessionAfterMins = "3 hours"; Break}    
                360             {$RASFeaturesResetIdleSessionAfterMins = "6 hours"; Break}    
                720             {$RASFeaturesResetIdleSessionAfterMins = "12 hours"; Break}    
                1440    {$RASFeaturesResetIdleSessionAfterMins = "1 day"; Break}    
                Default {$RASFeaturesResetIdleSessionAfterMins = "Unable to determine Console idle time: $($RASFeatures.ResetIdleSessionAfterMins)"; Break}    
        }                                                           $cnt++
                                                            $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                  
        If($MSWord -or $PDF)                                                           If($cnt -eq 0)
        {                                                           {
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Reset idle RAS Console session after"; Value = $RASFeaturesResetIdleSessionAfterMins; }) > $Null                                                                   $ScriptInformation.Add(@{Data = "     IPv4 Addresses"; Value = $tmp; }) > $Null
     
                $Table = AddWordTable -Hashtable $ScriptInformation `    
                -Columns Data,Value `    
                -List `    
                -Format $wdTableGrid `    
                -AutoFit $wdAutoFitFixed;    
     
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                $Table.Columns.Item(1).Width = 250;    
                $Table.Columns.Item(2).Width = 250;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
                WriteWordLine 0 0 ""    
        }                                                           }
        If($Text)                                                           Else
        {                                                           {
                Line 3 "Reset idle RAS Console session after`t`t`t: " $RASFeaturesResetIdleSessionAfterMins                                                                   $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null
                Line 0 ""    
        }                                                           }
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @("Reset idle RAS Console session after",($Script:htmlsb),$RASFeaturesResetIdleSessionAfterMins,$htmlwhite)    
     
                $msg = ""    
                $columnWidths = @("200","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }                                                   }
}                                           }
                                            
Function OutputRASMailboxSettings                                           If($RASMFASetting.ExcludeClientIPv6List.Count -gt 0)
{                                           {
        Param([object] $RASMailboxSettings)    
                                                          $cnt     = -1
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Mailbox"                                                   $MaxFrom = (($RASMFASetting.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                    $MaxTo   = (($RASMFASetting.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)
            
        If($MSWord -or $PDF)                                                   ForEach($Item in $RASMFASetting.ExcludeClientIPv6List)
        {                                                   {
                WriteWordLine 2 0 "Mailbox"    
                WriteWordLine 3 0 "Mailbox configuration"    
        }                                                           $cnt++
                                                            $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                            
        If($Text)                                                           If($cnt -eq 0)
        {                                                           {
                Line 1 "Mailbox"                                                                   $ScriptInformation.Add(@{Data = "     IPv6 Addresses"; Value = $tmp; }) > $Null
                Line 2 "Mailbox configuration"    
        }                                                           }
        If($HTML)    
        {                                                           Else
                WriteHTMLLine 2 0 "Mailbox"    
                WriteHTMLLine 3 0 "Mailbox configuration"    
        }    
            
        Switch ($RASMailboxSettings.UseTLS)    
        {                                                           {
                "YesIfAvailable"        {$RASMailboxSettingsUseTLS = "Use TLS/SSL if available"; Break}    
                "Yes"                           {$RASMailboxSettingsUseTLS = "Use TLS/SSL"; Break}    
                "No"                            {$RASMailboxSettingsUseTLS = "Do not use"; Break}    
                Default                         {$RASMailboxSettingsUseTLS = "Unable to determine TLS/SSL setting: $($RASMailboxSettings.UseTLS)"; Break}    
        }    
            
        If($MSWord -or $PDF)    
        {    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Mail server"; Value = $RASMailboxSettings.SMTPServer; }) > $Null    
                $ScriptInformation.Add(@{Data = "TLS/SSL"; Value = $RASMailboxSettingsUseTLS; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null
                $ScriptInformation.Add(@{Data = "SMTP server requires authentication"; Value = $RASMailboxSettings.RequireAuth; }) > $Null    
                If($RASMailboxSettings.RequireAuth)    
                {    
                        $ScriptInformation.Add(@{Data = "Username"; Value = $RASMailboxSettings.Username; }) > $Null    
                }                                                           }
     
                $Table = AddWordTable -Hashtable $ScriptInformation `    
                -Columns Data,Value `    
                -List `    
                -Format $wdTableGrid `    
                -AutoFit $wdAutoFitFixed;    
     
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                $Table.Columns.Item(1).Width = 250;    
                $Table.Columns.Item(2).Width = 250;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
                WriteWordLine 0 0 ""    
        }                                                   }
        If($Text)    
        {    
                Line 3 "Mail server`t`t`t`t`t`t: " $RASMailboxSettings.SMTPServer    
                Line 3 "TLS/SSL`t`t`t`t`t`t`t: " $RASMailboxSettingsUseTLS    
                Line 3 "SMTP server requires authentication`t`t`t: " $RASMailboxSettings.RequireAuth    
                If($RASMailboxSettings.RequireAuth)    
                {    
                        Line 3 "Username`t`t`t`t`t`t: " $RASMailboxSettings.Username    
                }                                           }
                Line 0 ""    
        }                                   }
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @("Mail server",($Script:htmlsb),$RASMailboxSettings.SMTPServer,$htmlwhite)    
                $rowdata += @(,("TLS/SSL",($Script:htmlsb),$RASMailboxSettingsUseTLS,$htmlwhite))    
                $rowdata += @(,("SMTP server requires authentication",($Script:htmlsb),$RASMailboxSettings.RequireAuth.ToString(),$htmlwhite))                                   $ScriptInformation.Add(@{Data = "Client MAC list"; Value = $RASMFASetting.ExcludeClientMAC.ToString(); }) > $Null
                If($RASMailboxSettings.RequireAuth)                                   If($RASMFASetting.ExcludeClientMAC)
                {                                   {
                        $rowdata += @(,("Username",($Script:htmlsb),$RASMailboxSettings.Username,$htmlwhite))    
                }    
                                            $cnt = -1
                $msg = ""                                           ForEach($MAC in $RASMFASetting.ExcludeClientMACList)
                $columnWidths = @("200","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
     
        If($MSWord -or $PDF)    
        {                                           {
                WriteWordLine 3 0 "Sender information"                                                   $cnt++
        }                                                   
        If($Text)                                                   If($cnt -eq 0)
        {                                                   {
                Line 2 "Sender information"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 3 0 "Sender information"    
        }    
            
        If($MSWord -or $PDF)    
        {    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Email address"; Value = $RASMailboxSettings.SenderAddress; }) > $Null                                                           $ScriptInformation.Add(@{Data = "     MAC Address"; Value = $MAC; }) > $Null
     
                $Table = AddWordTable -Hashtable $ScriptInformation `    
                -Columns Data,Value `    
                -List `    
                -Format $wdTableGrid `    
                -AutoFit $wdAutoFitFixed;    
     
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                $Table.Columns.Item(1).Width = 250;    
                $Table.Columns.Item(2).Width = 250;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
                WriteWordLine 0 0 ""    
        }                                                   }
        If($Text)    
        {    
                Line 3 "Email address`t`t`t`t`t`t: " $RASMailboxSettings.SenderAddress    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @("Email address",($Script:htmlsb),$RASMailboxSettings.SenderAddress,$htmlwhite)    
                                                    Else
                $msg = ""    
                $columnWidths = @("200","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }    
}    
     
Function OutputRASReportingSettings    
{                                                   {
        Param([object] $RASReportingSettings)                                                           $ScriptInformation.Add(@{Data = ""; Value = $MAC; }) > $Null
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput RAS Reporting configuration"    
            
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Reporting"    
        }                                                   }
        If($Text)    
        {    
                Line 1 "Reporting"    
        }                                           }
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Reporting"    
        }                                   }
            
        $SessionInfoRetain = ""                                   $ScriptInformation.Add(@{Data = "Connection to the following Gateway IPs"; Value = $RASMFASetting.ExcludeClientGWIPs.ToString(); }) > $Null
        Switch($RASReportingSettings.TrackSessionTime)                                   If($RASMFASetting.ExcludeClientGWIPs)
        {                                   {
                0                       {$SessionInfoRetain = "Do not delete"; Break}    
                7257600         {$SessionInfoRetain = "12 weeks"; Break}    
                15724800        {$SessionInfoRetain = "26 weeks"; Break}    
                31449600        {$SessionInfoRetain = "52 weeks"; Break}    
                Default         {$SessionInfoRetain = "Unable to determine Session retain info for: $($RASReportingSettings.TrackSessionTime)"; Break}    
        }                                           $cnt = -1
            
        $ServerInfoRetain = ""    
        Switch($RASReportingSettings.TrackServerTime)                                           ForEach($Server in $RASMFASetting.ExcludeClientGWIPList)
        {                                           {
                0                       {$ServerInfoRetain = "Do not delete"; Break}    
                2419200         {$ServerInfoRetain = "4 weeks"; Break}    
                4838400         {$ServerInfoRetain = "8 weeks"; Break}    
                7257600         {$ServerInfoRetain = "12 weeks"; Break}    
                15724800        {$ServerInfoRetain = "26 weeks"; Break}    
                31449600        {$ServerInfoRetain = "52 weeks"; Break}    
                Default         {$ServerInfoRetain = "Unable to determine Server retain info for: $($RASReportingSettings.TrackServerTime)"; Break}    
        }                                                   $cnt++
                                                          
        If($MSWord -or $PDF)                                                   If($cnt -eq 0)
        {                                                   {
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "RAS Reporting configuration"; Value = ""; }) > $Null    
                $ScriptInformation.Add(@{Data = "     Enable RAS Reporting"; Value = $RASReportingSettings.Enabled.ToString(); }) > $Null    
                If($RASReportingSettings.Enabled)    
                {    
                        $ScriptInformation.Add(@{Data = '     Server'; Value = $RASReportingSettings.Server; }) > $Null                                                           $ScriptInformation.Add(@{Data = "     Server Name"; Value = $Server; }) > $Null
                        $ScriptInformation.Add(@{Data = '     Port'; Value = $RASReportingSettings.Port.ToString(); }) > $Null    
                        If($RASReportingSettings.UseCredentials -eq $False)    
                        {    
                                $ScriptInformation.Add(@{Data = '     Prompt user for login details'; Value = ""; }) > $Null    
                        }                                                   }
                        Else                                                   Else
                        {                                                   {
                                $ScriptInformation.Add(@{Data = '     Use the following credentials:'; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = '     Username'; Value = $RASReportingSettings.Username; }) > $Null    
                        }    
     
                        $ScriptInformation.Add(@{Data = 'Session information'; Value = ""; }) > $Null    
                        $ScriptInformation.Add(@{Data = "     Enable Tracking"; Value = $RASReportingSettings.TrackSessions.ToString(); }) > $Null    
                        If($RASReportingSettings.TrackSessions)    
                        {    
                                $ScriptInformation.Add(@{Data = "     Retain information for"; Value = $SessionInfoRetain; }) > $Null    
                        }    
     
                        $ScriptInformation.Add(@{Data = "Server counters information"; Value = ""; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = $Server; }) > $Null
                        $ScriptInformation.Add(@{Data = "     Enable Tracking"; Value = $RASReportingSettings.TrackServers.ToString() ; }) > $Null    
                        If($RASReportingSettings.TrackServers)    
                        {    
                                $ScriptInformation.Add(@{Data = "     Retain information for"; Value = $ServerInfoRetain; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Track CPU counter when change is more than"; Value = "$($RASReportingSettings.DeltaCpu) %"; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Track Memory counter when change is more than"; Value = "$($RASReportingSettings.DeltaMemory) %"; }) > $Null    
                        }                                                   }
     
                        $ScriptInformation.Add(@{Data = "Custom reports"; Value = ""; }) > $Null    
                        $ScriptInformation.Add(@{Data = "     Enable custom reports"; Value = $RASReportingSettings.EnableCustomReports.ToString() ; }) > $Null    
                        If($RASReportingSettings.EnableCustomReports)    
                        {    
                                $ScriptInformation.Add(@{Data = "     Folder name"; Value = $RASReportingSettings.FolderName; }) > $Null    
                        }                                           }
                }                                   }
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 250;
                $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""#>
        }                           }
                    }
        If($Text)                   If($Text)
        {                   {
                Line 2 "RAS Reporting configuration"                            Line 2 "Provider settings"
                            Line 3 "Provider: " $RASMFASettingProvider
                            If($RASMFASettingProvider -ne "None")
                            {
                                    Line 3 "Settings"
                                    
                                    If($RASMFASetting.Type -eq "AzureRadius")
                                    {
                                            Line 4 "General"
                Line 3 "Enable RAS Reporting`t`t`t`t: " $RASReportingSettings.Enabled.ToString()                                           Line 5 "Enable MFA provider in site`t: " $RASMFASetting.Enabled.ToString()
                                            Line 5 "Name`t`t`t`t: " $RASMFASetting.Name
                                            Line 5 "Description`t`t`t: " $RASMFASetting.Description
                                            Line 5 "Type`t`t`t`t: " $RASMFASetting.DisplayName
                                            Line 4 "Connection"
                                            Line 5 "Display Name`t`t`t: " $RASMFASetting.DisplayName
                                            Line 5 "Primary server`t`t`t: " $RASMFASetting.Server
                                            Line 5 "Secondary server`t`t: " $RASMFASetting.BackupServer
                If($RASReportingSettings.Enabled)                                           If($RASMFASetting.HAMode -eq "Parallel")
                {                                           {
                                                    Line 5 "HA mode`t`t`t`t: Active - active (parallel)"
                                            }
                                            Else
                                            {
                                                    Line 5 "HA mode`t`t`t`t: Active - passive (failover)"
                                            }
                        Line 3 "Server`t`t`t`t`t`t: " $RASReportingSettings.Server                                           Line 5 "Port`t`t`t`t: " $RASMFASetting.Port
                                            Line 5 "Timeout (seconds)`t`t: " $RASMFASetting.Timeout
                        Line 3 "Port`t`t`t`t`t`t: " $RASReportingSettings.Port.ToString()                                           Line 5 "Retries`t`t`t`t: " $RASMFASetting.Retries
                                            Line 5 "Password Encoding`t`t: " $RASMFASetting.PasswordEncoding
                                            Line 5 "Forward username only to "
                        If($RASReportingSettings.UseCredentials -eq $False)                                           Line 5 "Radius Server`t`t`t: " $RASMFASetting.UsernameOnly.ToString()
                                            Line 5 "Forward the first password to "
                                            Line 5 "Windows authentication provider`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()
                                            Line 4 "Attributes"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                        {                                           {
                                                    $cnt++
                                                    Line 5 "Attribute $cnt"
                                                    Line 6 "Name`t: $($Item.RadiusAttrName)"
                                                    Line 6 "Vendor`t: $($Item.VendorID)"
                                                    Line 6 "Type`t: $($Item.AttributeType)"
                                                    Line 6 "Value`t: $($Item.Value)"
                                Line 3 "Prompt user for login details"                                                   Line 5 "" #blank separator line
                        }                                           }
                                            Line 5 "Automation"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "Automation $cnt"
                                                    Line 6 "Enable Action`t: $($Item.Enabled.ToString())"
                                                    Line 6 "Title`t`t: $($Item.Title)"
                                                    Line 6 "Command`t`t: $($Item.Command)"
                                                    Line 6 "Description`t: $($Item.Description)"
                                                    Line 6 "Action message`t: $($Item.ActionMessage)"
                                                    Line 6 "Image`t`t: $($Item.Image)"
                                                    Line 6 "Autosend`t: $($Item.AutoSend.ToString())"
                                                    Line 6 "" #blank separator line
                                            }
                                            Line 0 ""
                                    }
                                    ElseIf($RASMFASetting.Type -eq "DuoRadius")
                                    {
                                            Line 4 "Connection"
                                            Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName
                                            Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server
                                            Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                            }
                        Else                                           Else
                        {                                           {
                                                    Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                            }
                                            Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port
                                            Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout
                                            Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries
                                            Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding
                                            Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()
                                Line 3 "Use the following credentials:"                                           Line 5 "Forward the first password to "
                                            Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()
                                            Line 4 "Attributes"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "Attribute $cnt"
                                                    Line 6 "Name`t: $($Item.RadiusAttrName)"
                                                    Line 6 "Vendor`t: $($Item.VendorID)"
                                                    Line 6 "Type`t: $($Item.AttributeType)"
                                                    Line 6 "Value`t: $($Item.Value)"
                                                    Line 5 "" #blank separator line
                                            }
                                            Line 4 "Automation"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "" "Automation $cnt"
                                                    Line 6 "Enable Action`t: $($Item.Enabled.ToString())"
                                                    Line 6 "Title`t`t: $($Item.Title)"
                                                    Line 6 "Command`t`t: $($Item.Command)"
                                                    Line 6 "Description`t: $($Item.Description)"
                                Line 3 "Username`t`t`t`t`t: " $RASReportingSettings.Username                                                   Line 6 "Action message`t: $($Item.ActionMessage)"
                                                    Line 6 "Image`t`t: $($Item.Image)"
                                                    Line 6 "Autosend`t: $($Item.AutoSend.ToString())"
                                                    Line 5 "" "" #blank separator line
                        }                                           }
                                            Line 0 ""
                                    }
                                    ElseIf($RASMFASetting.Type -eq "FortiRadius")
                                    {
                        Line 2 "Session information"                                            Line 4 "Connection"
                                            Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName
                                            Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server
                                            Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                            }
                                            Else
                                            {
                                                    Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                            }
                                            Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port
                                            Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout
                                            Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries
                                            Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding
                                            Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()
                                            Line 5 "Forward the first password to "
                        Line 3 "Enable Tracking`t`t`t`t`t: " $RASReportingSettings.TrackSessions.ToString()                                           Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()
                                            Line 4 "Attributes"
                                            $cnt=0
                        If($RASReportingSettings.TrackSessions)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                        {                                           {
                                Line 3 "Retain information for`t`t`t`t: " $SessionInfoRetain                                                   $cnt++
                                                    Line 5 "Attribute $cnt"
                                                    Line 6 "Name  : $($Item.Name)"
                                                    Line 6 "Vendor: $($Item.Vendor)"
                                                    Line 6 "Type  : $($Item.AttributeType)"
                                                    Line 6 "Value : $($Item.Value)"
                                                    Line 5 "" #blank separator line
                        }                                           }
                                            Line 4 "Automation"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                        Line 2 "Server counters information"                                                    Line 5 "" "Automation $cnt"
                                                    Line 6 "Enabled : $($Item.Enabled.ToString())"
                                                    Line 6 "Title   : $($Item.Title)"
                                                    Line 6 "Command : $($Item.Command)"
                                                    Line 6 "Image   : $($Item.Image)"
                                                    Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                                    Line 5 "" "" #blank separator line
                                            }
                                            Line 0 ""
                                    }
                                    ElseIf($RASMFASetting.Type -eq "TekRadius")
                                    {
                                            Line 4 "Connection"
                                            Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName
                                            Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server
                                            Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                            }
                                            Else
                                            {
                                                    Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                            }
                                            Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port
                                            Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout
                                            Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries
                                            Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding
                                            Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()
                                            Line 5 "Forward the first password to "
                        Line 3 "Enable Tracking`t`t`t`t`t: " $RASReportingSettings.TrackServers.ToString()                                           Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()
                                            Line 4 "Attributes"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "Attribute $cnt"
                                                    Line 6 "Name  : $($Item.Name)"
                                                    Line 6 "Vendor: $($Item.Vendor)"
                                                    Line 6 "Type  : $($Item.AttributeType)"
                                                    Line 6 "Value : $($Item.Value)"
                                                    Line 5 "" #blank separator line
                                            }
                                            Line 4 "Automation"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "" "Automation $cnt"
                                                    Line 6 "Enabled : $($Item.Enabled.ToString())"
                                                    Line 6 "Title   : $($Item.Title)"
                                                    Line 6 "Command : $($Item.Command)"
                                                    Line 6 "Image   : $($Item.Image)"
                                                    Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                                    Line 5 "" "" #blank separator line
                                            }
                                            Line 0 ""
                                    }
                        If($RASReportingSettings.TrackServers)                                   ElseIf($RASMFASetting.Type -eq "Radius")
                        {                                   {
                                            Line 4 "Connection"
                                            Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName
                                Line 3 "Retain information for`t`t`t`t: " $ServerInfoRetain                                           Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server
                                            Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                            }
                                            Else
                                            {
                                                    Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                            }
                                            Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port
                                            Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout
                                            Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries
                                            Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding
                                Line 3 "Track CPU counter when change is more than`t: " "$($RASReportingSettings.DeltaCpu) %"                                           Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()
                                            Line 5 "Forward the first password to "
                                Line 3 "Track Memory counter when change is more than`t: " "$($RASReportingSettings.DeltaMemory) %"                                           Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()
                                            Line 4 "Attributes"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "Attribute $cnt"
                                                    Line 6 "Name  : $($Item.Name)"
                                                    Line 6 "Vendor: $($Item.Vendor)"
                                                    Line 6 "Type  : $($Item.AttributeType)"
                                                    Line 6 "Value : $($Item.Value)"
                                                    Line 5 "" #blank separator line
                        }                                           }
                                            Line 4 "Automation"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "" "Automation $cnt"
                                                    Line 6 "Enabled : $($Item.Enabled.ToString())"
                                                    Line 6 "Title   : $($Item.Title)"
                                                    Line 6 "Command : $($Item.Command)"
                                                    Line 6 "Image   : $($Item.Image)"
                                                    Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                                    Line 5 "" "" #blank separator line
                                            }
                                            Line 0 ""
                                    }
                                    ElseIf($RASMFASetting.Type -eq "Deepnet")
                                    {
                                            Line 4 "Connection"
                                            Line 5 "Type`t`t: " $RASMFASetting.DeepnetType
                                            Line 5 "Server`t`t: " $RASMFASetting.Server
                                            Line 5 "Port`t`t: " $RASMFASetting.Port.ToString()
                                            Line 5 "Enable SSL`t: " $RASMFASetting.SSL.ToString()
                                            Line 5 "Agent`t`t: " $RASMFASetting.DeepnetAgent
                                            Line 4 "Application"
                                            Line 5 "          Application`t: " $RASMFASetting.App
                                            Line 5 "          Domain`t: " $RASMFASetting.DefaultDomain
                                            Line 4 "Authentication"
                                            Line 5 "          Mode`t`t: " $DeepNetAuthMode
                                            Line 5 "          Token Type`t: " $RASMFASetting.TokenType.ToString()
                                            Line 5 "          Allow Channels: " "Email: $($RASMFASetting.ActivateEmail.ToString())"
                                            Line 5 "                          " "SMS: $($RASMFASetting.ActivateSMS.ToString())"
                                    }
                                    ElseIf($RASMFASetting.Type -eq "SafeNet")
                                    {
                                            Switch($RASMFASetting.AuthMode)
                                            {
                                                    "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}
                                                    "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                                    "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}
                                                    Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RASMFASetting.AuthMode)"; Break}
                                            }
 
  <>                                         Line 4 "Connection"
                                            Line 5 "OTP Service URL : " $RASMFASetting.DeepnetType
                                            Line 4 "Authentication"
                                            Line 5 "Mode`t`t`t: " $SafeNetAuthMode
                                            Line 5 "TMS Web API URL`t`t: " $RASMFASetting.TMSWebApiURL
                                            Line 5 "User Repository`t`t: " $RASMFASetting.UserRepository
                                    }
                                    ElseIf($RASMFASetting.Type -eq "GAuthTOTP")
                                    {
                                            Switch($RASMFASetting.UserEnrollment)
                                            {
                                                    "Allow"                 {$GAuthAllow = "Allow"; Break}
                                                    "AllowUntil"    {$GAuthAllow = "Allow until"; Break}
                                                    "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}
                                                    Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RASMFASetting.UserEnrollment)"; Break}
                                            }
                                            
                                            Switch($RASMFASetting.Tolerance)
                                            {
                                                    0               {$TOTPTolerance = "None"; Break}
                                                    30              {$TOTPTolerance = "+/- 30 seconds"; Break}
                                                    60              {$TOTPTolerance = "+/- 60 seconds"; Break}
                                                    90              {$TOTPTolerance = "+/- 90 seconds"; Break}
                                                    120             {$TOTPTolerance = "+/- 120 seconds"; Break}
                                                    Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}
                                            }
                                            
                                            Line 4 "Type Name: " $RASMFASetting.Type
                                            Line 4 "User Enrollment"
                                            Line 5 $GAuthAllow
                                            If($GAuthAllow -eq "Allow until")
                                            {
                                                    $GAuthFullDate = $RASMFASetting.UntilDateTime
                                                    $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()
                                                    $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()
                                                    Line 6 "Date: " $GAuthDate
                                                    Line 6 "Time: " $GAuthTime
                                            }
                                            Line 4 "Authentication"
                                            Line 5 "TOTP tolerence: " $TOTPTolerance
                                    }
     
                                    <#If($RASMFASetting.RestrictionMode -eq "Exclusion")
                                    {
                                            Line 3 "Enable MFA for all users except"
                                    }
                                    Else
                                    {
                                            Line 3 "Disable MFA for all users except"
                                    }#>
                                    Line 0 ""
     
                        Line 2 "Custom reports"                                   <#Line 2 "Restriction"
                        Line 3 "Enable custom reports`t`t`t`t: " $RASReportingSettings.EnableCustomReports.ToString()                                   Line 3 "User or group list`t`t`t: " $RASMFASetting.ExcludeUserGroup.ToString()
                                    If($RASMFASetting.ExcludeUserGroup)
                                    {
                        If($RASReportingSettings.EnableCustomReports)                                           If($RASMFASetting.ExcludeUserGroupList.Count -gt 0)
                        {                                           {
                                                    ForEach($Item in $RASMFASetting.ExcludeUserGroupList)
                                                    {
                                                            Line 8 "  " "User: $($Item.Account)"
                                                            Line 8 "  " "Type: $($Item.Type)"
                                                            Line 8 "  "
                                                    }
                                            }
                                    }
                                            
                                Line 3 "Folder name`t`t`t`t`t: " $RASReportingSettings.FolderName                                   Line 3 "Client IP list`t`t`t`t: " $RASMFASetting.ExcludeClientIPs.ToString()
                                    If($RASMFASetting.ExcludeClientIPs)
                                    {
                                            If($RASMFASetting.ExcludeClientIPList.Count -gt 0)
                                            {
                                                    $cnt     = -1
                                                    $MaxFrom = (($RASMFASetting.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                    $MaxTo   = (($RASMFASetting.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)
     
                                                    ForEach($Item in $RASMFASetting.ExcludeClientIPList)
                                                    {
                                                            $cnt++
                                                            $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                            
                                                            If($cnt -eq 0)
                                                            {
                                                                    Line 6 "IPv4 Addresses`t: " $tmp
                        }                                                           }
                                                            Else
                                                            {
                                                                    Line 8 "  " $tmp
                }                                                           }
                                                    }
                                            }
                                            
                                            If($RASMFASetting.ExcludeClientIPv6List.Count -gt 0)
                                            {
                                                    $cnt     = -1
                                                    $MaxFrom = (($RASMFASetting.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                    $MaxTo   = (($RASMFASetting.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)
     
                                                    ForEach($Item in $RASMFASetting.ExcludeClientIPv6List)
                                                    {
                                                            $cnt++
                                                            $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                            
                                                            If($cnt -eq 0)
                                                            {
                                                                    Line 6 "IPv6 Addresses`t: " $tmp
                                                            }
                                                            Else
                                                            {
                                                                    Line 8 "  " $tmp
                                                            }
                                                    }
                                            }
                                    }
                                    Line 3 "Client MAC list`t`t`t`t: " $RASMFASetting.ExcludeClientMAC.ToString()
                                    If($RASMFASetting.ExcludeClientMAC)
                                    {
                                            $cnt = -1
                                            ForEach($MAC in $RASMFASetting.ExcludeClientMACList)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            Line 6 "MAC Address`t: " $MAC
                                                    }
                                                    Else
                                                    {
                                                            Line 8 "  " $MAC
                                                    }
                                            }
                                    }
                                    Line 3 "Connection to the following Gateway IPs`t: " $RASMFASetting.ExcludeClientGWIPs.ToString()
                                    If($RASMFASetting.ExcludeClientGWIPs)
                                    {
                                            $cnt = -1
                                            ForEach($Server in $RASMFASetting.ExcludeClientGWIPList)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            Line 6 "Server Name`t: " $Server
                                                    }
                                                    Else
                                                    {
                                                            Line 8 "  " $Server
                                                    }
                                            }
                                    }#>
                            }
                Line 0 ""                           Line 0 ""
        }                   }
        If($HTML)                   If($HTML)
        {                   {
                $rowdata = @()                           $rowdata = @()
                $columnHeaders = @("RAS Reporting configuration",($Script:htmlsb),"",$htmlwhite)                           $columnHeaders = @("Provider",($Script:htmlsb),$RASMFASettingProvider,$htmlwhite)
                            If($RASMFASettingProvider -ne "None")
                            {
                                    If($RASMFASetting.Type -eq "AzureRadius")
                                    {
                                            $rowdata += @(,( "     General",($Script:htmlsb),"",$htmlwhite))
                $rowdata += @(,("     Enable RAS Reporting",($Script:htmlsb),$RASReportingSettings.Enabled.ToString(),$htmlwhite))                                           $rowdata += @(,("          Enable MFA provider in site",($Script:htmlsb),$RASMFASetting.Enabled.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Name",($Script:htmlsb),$RASMFASetting.Name,$htmlwhite))
                                            $rowdata += @(,("          Description",($Script:htmlsb), $RASMFASetting.Description,$htmlwhite))
                                            $rowdata += @(,("          Type",($Script:htmlsb), $RASMFASetting.DisplayName,$htmlwhite))
                                            $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("          Display Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))
                                            $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))
                                            $rowdata += @(,("          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                            }
                                            $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))
                                            $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))
                                            $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))
                                            $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                            $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.RadiusAttrName)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.VendorID)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                            }
                                            $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Enabled Action: $($Item.Enabled.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Description: $($Item.Description)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Action message: $($Item.ActionMessage)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                            }
                                    }
                If($RASReportingSettings.Enabled)                                   ElseIf($RASMFASetting.Type -eq "DuoRadius")
                {                                   {
                                            $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))
                                            $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))
                        $rowdata += @(,("     Server",($Script:htmlsb),$RASReportingSettings.Server,$htmlwhite))                                           $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                            }
                        $rowdata += @(,("     Port",($Script:htmlsb),$RASReportingSettings.Port.ToString(),$htmlwhite))                                           $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))
                                            $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))
                                            $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))
                                            $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                            $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                            }
                                            $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                            }
                                    }
                        If($RASReportingSettings.UseCredentials -eq $False)                                   ElseIf($RASMFASetting.Type -eq "FortiRadius")
                        {                                   {
                                $rowdata += @(,("     Prompt user for login details",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))
                                            $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))
                                            $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                        }                                           }
                        Else                                           Else
                        {                                           {
                                $rowdata += @(,("     Use the following credentials:",($Script:htmlsb),"",$htmlwhite))                                                   $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                            }
                                            $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))
                                            $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))
                                $rowdata += @(,("     Username",($Script:htmlsb),$RASReportingSettings.Username,$htmlwhite))                                           $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))
                                            $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                            $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                        }                                           }
                                            $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                            }
                                    }
                                    ElseIf($RASMFASetting.Type -eq "TekRadius")
                                    {
                        $rowdata += @(,("Session information",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))
                                            $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))
                                            $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                            }
                                            $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))
                                            $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))
                                            $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))
                        $rowdata += @(,("     Enable Tracking",($Script:htmlsb), $RASReportingSettings.TrackSessions.ToString(),$htmlwhite))                                           $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                            $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                        If($RASReportingSettings.TrackSessions)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                        {                                           {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                $rowdata += @(,("     Retain information for",($Script:htmlsb), $SessionInfoRetain,$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                        }                                           }
                                            $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                        $rowdata += @(,("Server counters information",($Script:htmlsb),"",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                        $rowdata += @(,("     Enable Tracking",($Script:htmlsb),$RASReportingSettings.TrackServers.ToString(),$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                            }
                                    }
                        If($RASReportingSettings.TrackServers)                                   ElseIf($RASMFASetting.Type -eq "Radius")
                        {                                   {
                                            $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))
                                $rowdata += @(,("     Retain information for",($Script:htmlsb),$ServerInfoRetain,$htmlwhite))                                           $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))
                                            $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                            }
                                            $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))
                                            $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))
                                            $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))
                                $rowdata += @(,("     Track CPU counter when change is more than",($Script:htmlsb),"$($RASReportingSettings.DeltaCpu) %",$htmlwhite))                                           $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))
                                $rowdata += @(,("     Track Memory counter when change is more than",($Script:htmlsb),"$($RASReportingSettings.DeltaMemory) %",$htmlwhite))                                           $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                            $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                        }                                           }
                                            $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                            }
                                    }
                                    ElseIf($RASMFASetting.Type -eq "Deepnet")
                                    {
                                            $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,( "          Type",($Script:htmlsb), $RASMFASetting.DeepnetType,$htmlwhite))
                                            $rowdata += @(,( "          Server",($Script:htmlsb), $RASMFASetting.Server,$htmlwhite))
                                            $rowdata += @(,( "          Port",($Script:htmlsb), $RASMFASetting.Port.ToString(),$htmlwhite))
                                            $rowdata += @(,( "          Enable SSL",($Script:htmlsb), $RASMFASetting.SSL.ToString(),$htmlwhite))
                                            $rowdata += @(,( "          Agent",($Script:htmlsb), $RASMFASetting.DeepnetAgent,$htmlwhite))
                                            $rowdata += @(,( "     Application",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,( "          Application",($Script:htmlsb), $RASMFASetting.App,$htmlwhite))
                                            $rowdata += @(,( "          Domain",($Script:htmlsb), $RASMFASetting.DefaultDomain,$htmlwhite))
                                            $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,( "          Mode",($Script:htmlsb), $DeepNetAuthMode,$htmlwhite))
                                            $rowdata += @(,( "          Token Type",($Script:htmlsb), $RASMFASetting.TokenType.ToString(),$htmlwhite))
                                            $rowdata += @(,( "          Allow Channels",($Script:htmlsb), "Email: $($RASMFASetting.ActivateEmail.ToString())",$htmlwhite))
                                            $rowdata += @(,( "                        ",($Script:htmlsb), "SMS: $($RASMFASetting.ActivateSMS.ToString())",$htmlwhite))
                                    }
                                    ElseIf($RASMFASetting.Type -eq "SafeNet")
                                    {
                                            Switch($RASMFASetting.AuthMode)
                                            {
                                                    "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}
                                                    "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                                    "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}
                                                    Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RASMFASetting.AuthMode)"; Break}
                                            }
 
                        $rowdata += @(,("Custom reports",($Script:htmlsb),"",$htmlwhite)) <>                                         $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,( "          OTP Service URL",($Script:htmlsb),$RASMFASetting.OTPServiceURL,$htmlwhite))
                                            $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,( "          Mode",($Script:htmlsb), $SafeNetAuthMode,$htmlwhite))
                                            $rowdata += @(,( "          TMS Web API URL",($Script:htmlsb), $RASMFASetting.TMSWebApiURL,$htmlwhite))
                                            $rowdata += @(,( "          User Repository",($Script:htmlsb), $RASMFASetting.UserRepository,$htmlwhite))
                                    }
                                    ElseIf($RASMFASetting.Type -eq "GAuthTOTP")
                                    {
                                            Switch($RASMFASetting.UserEnrollment)
                                            {
                                                    "Allow"                 {$GAuthAllow = "Allow"; Break}
                                                    "AllowUntil"    {$GAuthAllow = "Allow until"; Break}
                                                    "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}
                                                    Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RASMFASetting.UserEnrollment)"; Break}
                                            }
                                            
                                            Switch($RASMFASetting.Tolerance)
                                            {
                                                    0               {$TOTPTolerance = "None"; Break}
                                                    30              {$TOTPTolerance = "+/- 30 seconds"; Break}
                                                    60              {$TOTPTolerance = "+/- 60 seconds"; Break}
                                                    90              {$TOTPTolerance = "+/- 90 seconds"; Break}
                                                    120             {$TOTPTolerance = "+/- 120 seconds"; Break}
                                                    Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}
                                            }
                                            
                                            $rowdata += @(,( "     Type Name",($Script:htmlsb),$RASMFASetting.Type,$htmlwhite))
                                            $rowdata += @(,( "     User Enrollment",($Script:htmlsb),"",$htmlwhite))
                                            If($GAuthAllow -eq "Allow until")
                                            {
                                                    $GAuthFullDate = $RASMFASetting.UntilDateTime
                                                    $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()
                                                    $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()
                                                    $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"Date: $GAuthDate",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb),"Time: $GAuthTime",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"",$htmlwhite))
                                            }
                                            $rowdata += @(,( "     Authentication",($Script:htmlsb), "",$htmlwhite))
                                            $rowdata += @(,( "          TOTP tolerence",($Script:htmlsb), $TOTPTolerance,$htmlwhite))
                                    }
     
                                    <#If($RASMFASetting.RestrictionMode -eq "Exclusion")
                                    {
                                            $rowdata += @(,("Enable MFA for all users except",($Script:htmlsb),"",$htmlwhite))
                                    }
                                    Else
                                    {
                                            $rowdata += @(,("Disable MFA for all users except",($Script:htmlsb),"",$htmlwhite))
                                    }#>
     
                                    $msg = "Provider settings"
                                    $columnWidths = @("300","175")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    <#
                                    $rowdata = @()
                        $rowdata += @(,("     Enable custom reports",($Script:htmlsb),$RASReportingSettings.EnableCustomReports.ToString(),$htmlwhite))                                   $columnHeaders = @("User or group list",($Script:htmlsb),$RASMFASetting.ExcludeUserGroup.ToString(),$htmlwhite)
                                    If($RASMFASetting.ExcludeUserGroup)
                                    {
                        If($RASReportingSettings.EnableCustomReports)                                           If($RASMFASetting.ExcludeUserGroupList.Count -gt 0)
                        {                                           {
                                                    ForEach($Item in $RASMFASetting.ExcludeUserGroupList)
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),"User: $($Item.Account)",$htmlwhite))
                                                            $rowdata += @(,("",($Script:htmlsb),"Type: $($Item.Type)",$htmlwhite))
                                                            $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                    }
                                            }
                                    }
                                    
                                    $rowdata += @(,("Client IP list",($Script:htmlsb),$RASMFASetting.ExcludeClientIPs.ToString(),$htmlwhite))
                                    If($RASMFASetting.ExcludeClientIPs)
                                    {
                                            If($RASMFASetting.ExcludeClientIPList.Count -gt 0)
                                            {
                                                    $cnt     = -1
                                                    $MaxFrom = (($RASMFASetting.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                    $MaxTo   = (($RASMFASetting.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)
     
                                                    ForEach($Item in $RASMFASetting.ExcludeClientIPList)
                                                    {
                                                            $cnt++
                                                            $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                            
                                                            If($cnt -eq 0)
                                                            {
                                                                    $rowdata += @(,("     IPv4 Addresses",($Script:htmlsb),$tmp,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))
                                                            }
                                                    }
                                            }
                                            
                                            If($RASMFASetting.ExcludeClientIPv6List.Count -gt 0)
                                            {
                                                    $cnt     = -1
                                                    $MaxFrom = (($RASMFASetting.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                    $MaxTo   = (($RASMFASetting.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)
     
                                                    ForEach($Item in $RASMFASetting.ExcludeClientIPv6List)
                                                    {
                                                            $cnt++
                                                            $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                            
                                                            If($cnt -eq 0)
                                                            {
                                                                    $rowdata += @(,("     IPv6 Addresses",($Script:htmlsb),$tmp,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))
                                                            }
                                                    }
                                            }
                                    }
                                    $rowdata += @(,("Client MAC list",($Script:htmlsb),$RASMFASetting.ExcludeClientMAC.ToString(),$htmlwhite))
                                    If($RASMFASetting.ExcludeClientMAC)
                                    {
                                            $cnt = -1
                                            ForEach($MAC in $RASMFASetting.ExcludeClientMACList)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $rowdata += @(,("     MAC Address",($Script:htmlsb),$MAC,$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),$MAC,$htmlwhite))
                                                    }
                                            }
                                    }
                                    $rowdata += @(,("Connection to the following Gateway IPs",($Script:htmlsb),$RASMFASetting.ExcludeClientGWIPs.ToString(),$htmlwhite))
                                    If($RASMFASetting.ExcludeClientGWIPs)
                                    {
                                            $cnt = -1
                                            ForEach($Server in $RASMFASetting.ExcludeClientGWIPList)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                $rowdata += @(,("     Folder name",($Script:htmlsb),$RASReportingSettings.FolderName,$htmlwhite))                                                           $rowdata += @(,("     Server Name",($Script:htmlsb),$Server,$htmlwhite))
                        }                                                   }
                                                    Else
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),$Server,$htmlwhite))
                }                                                   }
                                            }
                                    }
                                    
                $msg = ""                                   $msg = "Restriction"
                $columnWidths = @("300","175")                                   $columnWidths = @("300","175")
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                    #>
                            }
                    }
 
Function OutputRASPerformanceMonitorSettings <> Function OutputRASAllowedDevicesSetting
 
        Param([object] $RASPerformanceMonitorSettings) <>         Param([object] $RASAllowedDevices)
 
        Write-Verbose "$(Get-Date -Format G): `t`tOutput RAS Performance Monitor configuration" <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput Allowed devices"
 
  -+         Switch ($RASAllowedDevices.AllowClientMode)
            {
                    "AllowAllClientsConnectToSystem"                        
                            {$RASAllowedDevicesAllowClientMode = "Allow all clients to connect to the system"; Break}
                    "AllowSelectedClientsConnectToSystem"           
                            {$RASAllowedDevicesAllowClientMode = "Allow only the selected clients to connect to the system"; Break}
                    "AllowSelectedClientsListPublishedItems"        
                            {$RASAllowedDevicesAllowClientMode = "Allow only the selected clients to list the published items"; Break}
                    Default                                                                         
                            {$RASAllowedDevicesAllowClientMode = "Unable to determine Allow Client Mode: $($RASAllowedDevices.AllowClientMode)"; Break}
            }
            
 
  -+                 WriteWordLine 2 0 "Allowed devices"
 
                $ScriptInformation.Add(@{Data = "RAS Performance Monitor configuration"; Value = ""; }) > $Null <>                 $ScriptInformation.Add(@{Data = "Secure Access"; Value = ""; }) > $Null
                $ScriptInformation.Add(@{Data = "     Enable RAS Performance Monitor"; Value = $RASPerformanceMonitorSettings.Enabled.ToString(); }) > $Null                   $ScriptInformation.Add(@{Data = "     Allow only clients with the latest security patches"; Value = $RASAllowedDevices.AllowClientWithSecurityPatchesOnly.ToString(); }) > $Null
                If($RASPerformanceMonitorSettings.Enabled)    
                {    
                        $ScriptInformation.Add(@{Data = '     Server'; Value = $RASPerformanceMonitorSettings.Server; }) > $Null                   $ScriptInformation.Add(@{Data = "Device Access"; Value = ""; }) > $Null
                        $ScriptInformation.Add(@{Data = '     Port'; Value = $RASPerformanceMonitorSettings.Port.ToString(); }) > $Null                   $ScriptInformation.Add(@{Data = "     Mode"; Value = $RASAllowedDevicesAllowClientMode; }) > $Null
                }    
 
                $Table.Columns.Item(2).Width = 250; <>                 $Table.Columns.Item(2).Width = 175;
 
        } <>  
        If($Text)                   $AllowedDevicesWordTable = @()
        {                   
                Line 2 "RAS Performance Monitor configuration"                   $AllowedDevicesWordTable += @{
                Line 3 "Enable RAS Performance Monitor`t`t`t: " $RASPerformanceMonitorSettings.Enabled.ToString()                           ClientStatus       = $RASAllowedDevices.AllowClientAndroid
                If($RASPerformanceMonitorSettings.Enabled)                           ClientName         = "Android client"
                {                           ClientMinimumBuild = $RASAllowedDevices.MinBuildAndroid
                        Line 3 "Server`t`t`t`t`t``t: " $RASPerformanceMonitorSettings.Server    
                        Line 3 "Port`t`t`t`t`t``t: " $RASPerformanceMonitorSettings.Port.ToString()    
 
                Line 0 "" <>  
        }                   
        If($HTML)                   $AllowedDevicesWordTable += @{
        {                           ClientStatus       = $RASAllowedDevices.AllowClientChromeApp
                $rowdata = @()                           ClientName         = "Chrome OS client"
                $columnHeaders = @("RAS Performance Monitor configuration",($Script:htmlsb),"",$htmlwhite)                           ClientMinimumBuild = $RASAllowedDevices.MinBuildChromeApp
                $rowdata += @(,("     Enable RAS Performance Monitor",($Script:htmlsb),$RASPerformanceMonitorSettings.Enabled.ToString(),$htmlwhite))    
                If($RASPerformanceMonitorSettings.Enabled)    
                {    
                        $rowdata += @(,("     Server",($Script:htmlsb),$RASPerformanceMonitorSettings.Server,$htmlwhite))    
                        $rowdata += @(,("     Port",($Script:htmlsb),$RASPerformanceMonitorSettings.Port.ToString(),$htmlwhite))    
 
  <>                 
                $msg = ""                   $AllowedDevicesWordTable += @{
                $columnWidths = @("300","175")                           ClientStatus       = $RASAllowedDevices.AllowClientIOS
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                           ClientName         = "iOS/iPadOS client"
                WriteHTMLLine 0 0 ""                           ClientMinimumBuild = $RASAllowedDevices.MinBuildIOS
        }                   }
}    
     
Function OutputRASNotifications    
{    
        Param([object] $RASNotificationHandlers)    
                          
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Notifications"                   $AllowedDevicesWordTable += @{
                                  ClientStatus       = $RASAllowedDevices.AllowClientLinux
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 3 0 "Notifications"    
                WriteWordLine 4 0 "Notification handlers"                           ClientName         = "Linux client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildLinux
        }                   }
        If($Text)    
        {                   
                Line 1 "Notifications"                   $AllowedDevicesWordTable += @{
                            ClientStatus       = $RASAllowedDevices.AllowClientMAC
                Line 2 "Notification handlers"                           ClientName         = "macOS client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildMAC
        }                   }
        If($HTML)    
        {                   
                WriteHTMLLine 3 0 "Notifications"                   $AllowedDevicesWordTable += @{
                            ClientStatus       = $RASAllowedDevices.AllowClientWeb
                WriteHTMLLine 4 0 "Notification handlers"                           ClientName         = "User Portal (Web client)"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildWeb
        }                   }
                          
        ForEach($RASNotificationHandler in $RASNotificationHandlers)                   $AllowedDevicesWordTable += @{
        {    
                If($RASNotificationHandler.HasThreshold)    
                {    
                        Switch ($RASNotificationHandler.Direction)                           ClientStatus       = $RASAllowedDevices.AllowClientWindows
                        {    
                                "LowersBelow"   {$RASNotificationHandlerDirection = "Decreases below"; Break}    
                                "RisesAbove"    {$RASNotificationHandlerDirection = "Rises above"; Break}    
                                Default                 {$RASNotificationHandlerDirection = "Unable to determine notification direction: $($RASNotificationHandler.Direction)"; Break}    
                        }    
                }    
                Else    
                {    
                        $RASNotificationHandlerDirection = ""                           ClientName         = "Windows client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildWindows
 
                Switch ($RASNotificationHandler.Type) <>                 $AllowedDevicesWordTable += @{
                {    
                        #listed in the order they appear in the console    
                        "CPUEvent"                                              {$RASNotificationText = "CPU utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break}    
                        "MemoryEvent"                                   {$RASNotificationText = "Memory utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break}    
                        "ConnectedSessionEvent"                 {$RASNotificationText = "Number of RDSH sessions $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}    
                        "DisconnectSessionEvent"                {$RASNotificationText = "Number of disconnected RDSH sessions $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}    
                        "RDSHConnectSessionEvent"               {$RASNotificationText = "RDSH sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break}    
                        "RDSHDisconnectSessionEvent"    {$RASNotificationText = "RDSH disconnected sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}    
                        "TunneledSess"                                  {$RASNotificationText = "Number of gateway tunnelled sessions $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}    
                        "GW"                                                    {$RASNotificationText = "Failed gateway tunnelled sessions"; Break}                           ClientStatus       = $RASAllowedDevices.AllowClientWyse
                        "1097729"                                               {$RASNotificationText = "Failed gateway tunnelled sessions"; Break}                           ClientName         = "Wyse client"
                        "Agent"                                                 {$RASNotificationText = "RAS Agents events"; Break}                           ClientMinimumBuild = $RASAllowedDevices.MinBuildWyse
                        "License"                                               {$RASNotificationText = "Licensing events"; Break}    
                        "Authentication"                                {$RASNotificationText = "Authentication server events"; Break}    
                        "PubItem"                                               {$RASNotificationText = "Published items events"; Break}    
                        "VDI"                                                   {$RASNotificationText = "Template events"; Break}    
                        "45056"                                                 {$RASNotificationText = "Tenants"; Break}    
                        "Unknown"                                               {$RASNotificationText = "Unknown"; Break}    
                        Default                                                 {$RASNotificationText = "Unable to determine event type: $($RASNotificationHandler.Type)"; Break}    
     
                        #"CPU"                                                  {$RASNotificationText = ""; Break}    
                        #"Disk"                                                 {$RASNotificationText = ""; Break}    
                        #"Memory"                                               {$RASNotificationText = ""; Break}    
                        #"RDSH"                                                 {$RASNotificationText = ""; Break}    
 
                $GracePeriod           = ($RASNotificationHandler.GracePeriod / 60) <>  
                $NotificationsInterval = ($RASNotificationHandler.Interval / 60)    
                    
                If($MSWord -or $PDF)    
                {    
                        $ScriptInformation = New-Object System.Collections.ArrayList    
                        $ScriptInformation.Add(@{Data = "Events"; Value = $RASNotificationText; }) > $Null    
                        $ScriptInformation.Add(@{Data = 'Enabled'; Value = $RASNotificationHandler.Enabled.ToString(); }) > $Null    
                        If($RASNotificationHandler.Enabled)                   If($AllowedDevicesWordTable.Count -gt 0)
                        {                   {
                                $ScriptInformation.Add(@{Data = 'Send email to RAS administrators'; Value = $RASNotificationHandler.SendEmail; }) > $Null                           $Table = AddWordTable -Hashtable $AllowedDevicesWordTable `
                                                          -Columns ClientStatus, ClientName, ClientMinimumBuild `
                                If($RASNotificationHandler.Recipients -eq "")                           -Headers "Enabled", "Clients", "Minimum build" `
                                {                           -Format $wdTableGrid `
                                        $ScriptInformation.Add(@{Data = 'Handler'; Value = ""; }) > $Null                           -AutoFit $wdAutoFitFixed;
                                }    
                                Else                           SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
                                {    
                                        $tmpArray = $RASNotificationHandler.Recipients.Split(",").Split(";")                           $Table.Columns.Item(1).Width = 50;
                            $Table.Columns.Item(2).Width = 125;
                            $Table.Columns.Item(3).Width = 100;
                                                                  
                                        $cnt = -1                           $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
                                        ForEach($item in $tmpArray)    
                                        {    
                                                $cnt++                           FindWordDocumentEnd
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = 'Handler'; Value = $item; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ''; Value = $item; }) > $Null    
                                                }    
                                        }    
                                        $tmpArray = $Null                           $Table = $Null
                            WriteWordLine 0 0 ""
                                }                   }
                                $ScriptInformation.Add(@{Data = 'Execute a notification script'; Value = $RASNotificationHandler.ExecuteScript; }) > $Null    
                                    
                                If($RASNotificationHandler.ExecuteScript)    
                                {    
                                        $results = Get-RASNotificationScript -id $RASNotificationHandler.ScriptId -EA 0 4>$Null    
                                            
                                        If(!($?))    
                                        {    
                                                $ScriptName = "Unable to retrieve script name"                   $ScriptInformation = New-Object System.Collections.ArrayList
                                        }    
                                        Else    
                                        {    
                                                $ScriptName = $results.Name    
                                        }    
                                            
                                        $ScriptInformation.Add(@{Data = ''; Value = $ScriptName; }) > $Null    
                                        $ScriptName = $Null    
                                }    
     
                                $ScriptInformation.Add(@{Data = 'Notification handler grace period'; Value = "$GracePeriod minutes"; }) > $Null                   $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASAllowedDevices.ReplicateSettings.ToString(); }) > $Null
                                If($RASNotificationHandler.EnableInterval)    
                                {    
                                        $ScriptInformation.Add(@{Data = 'Notifications interval'; Value = "$NotificationsInterval minutes"; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = 'Send one notification and suspend further notifications until recovered'; Value = ""; }) > $Null    
                                }    
                        }    
 
                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                 $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                   -Columns Data,Value `
                        -List `                   -List `
                        -Format $wdTableGrid `                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 200; <>                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 250;                   $Table.Columns.Item(2).Width = 100;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                 FindWordDocumentEnd
                        $Table = $Null                   $Table = $Null
                        WriteWordLine 0 0 ""                   WriteWordLine 0 0 ""
                }           }
                If($Text)           If($Text)
                {           {
                        Line 3 "Events`t`t`t`t`t: " $RASNotificationText                   Line 0 "Allowed devices"
                    Line 1 "Secure Access"
                    Line 2 "Allow only clients with the latest security patches: " $RASAllowedDevices.AllowClientWithSecurityPatchesOnly.ToString()
                    Line 1 "Device Access"
                    Line 2 "Mode: " $RASAllowedDevicesAllowClientMode
                    Line 0 ""
                    Line 2 "Enabled Clients                  Minimum build"
                    Line 2 "=============================================="
                    #               1234567S123456789012345678901234S12345
                    #       False   User Portal (Web client) 99999
                    Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientWindows, "Windows client", $RASAllowedDevices.MinBuildWindows)
                    Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientWeb, "User Portal (Web client)", $RASAllowedDevices.MinBuildWeb)
                    Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientMAC, "macOS client", $RASAllowedDevices.MinBuildMAC)
                    Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientLinux, "Linux client", $RASAllowedDevices.MinBuildLinux)
                    Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientIOS, "iOS/iPadOS client", $RASAllowedDevices.MinBuildIOS)
                    Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientAndroid, "Android client", $RASAllowedDevices.MinBuildAndroid)
                    Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientChromeApp, "Chrome OS client", $RASAllowedDevices.MinBuildChromeApp)
                    Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientWyse, "Wyse client", $RASAllowedDevices.MinBuildWyse)
                    Line 0 ""
                        Line 3 "Enabled`t`t`t`t`t: " $RASNotificationHandler.Enabled.ToString()                   Line 2 "Settings are replicated to all Sites: " $RASAllowedDevices.ReplicateSettings.ToString()
                        If($RASNotificationHandler.Enabled)                   Line 0 ""
            }
            If($HTML)
                        {           {
                                Line 3 "Send email to RAS administrators`t: " $RASNotificationHandler.SendEmail                   WriteHTMLLine 2 0 "Allowed devices"
     
                    $rowdata = @()
                    $columnHeaders = @("Allow only clients with the latest security patches",($Script:htmlsb),$RASAllowedDevices.AllowClientWithSecurityPatchesOnly.ToString(),$htmlwhite)
     
                    $msg = "Secure Access"
                    $columnWidths = @("300","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
     
                    $rowdata = @()
                    $columnHeaders = @("Mode",($Script:htmlsb),$RASAllowedDevicesAllowClientMode,$htmlwhite)
     
                    $msg = "Device Access"
                    $columnWidths = @("300","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
     
                    $rowdata = @()
     
                    $rowdata += @(,($RASAllowedDevices.AllowClientWindows,$htmlwhite,"Windows client",$htmlwhite,$RASAllowedDevices.MinBuildWindows,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClientWeb,$htmlwhite,"User Portal (Web client)",$htmlwhite,$RASAllowedDevices.MinBuildWeb,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClientMAC,$htmlwhite,"macOS client",$htmlwhite,$RASAllowedDevices.MinBuildMAC,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClientLinux,$htmlwhite,"Linux client",$htmlwhite,$RASAllowedDevices.MinBuildLinux,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClientIOS,$htmlwhite,"iOS/iPadOS client",$htmlwhite,$RASAllowedDevices.MinBuildIOS,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClientAndroid,$htmlwhite,"Android client",$htmlwhite,$RASAllowedDevices.MinBuildAndroid,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClientChromeApp,$htmlwhite,"Chrome OS client",$htmlwhite,$RASAllowedDevices.MinBuildChromeApp,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClientWyse,$htmlwhite,"Wyse client",$htmlwhite,$RASAllowedDevices.MinBuildWyse,$htmlwhite))
                                                  
                                If($RASNotificationHandler.Recipients -eq "")                   $columnHeaders = @(
                    "Enabled",($Script:htmlsb),
                    "Clients",($Script:htmlsb),
                    "Minimum build",($Script:htmlsb))
     
                    $msg = ""
                    $columnWidths = @("55","175","100")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
     
                    $rowdata = @()
                    $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$RASAllowedDevices.ReplicateSettings.ToString(),$htmlwhite)
     
                    $msg = ""
                    $columnWidths = @("183","100")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
                                {           }
                                        Line 3 "Handler`t`t`t`t`t: " ""    
                                }   }
    #endregion
                                Else    
    #region process policies
    Function ProcessPolicies
                                {   {
                                        $tmpArray = $RASNotificationHandler.Recipients.Split(",").Split(";")           Write-Verbose "$(Get-Date -Format G): Processing Policies"
                                                  
            OutputPoliciesSectionPage
                                        $cnt = -1          
                                        ForEach($item in $tmpArray)           Write-Verbose "$(Get-Date -Format G): `tProcessing Policies Summary"
            
            $Policies = Get-RASClientPolicy -EA 0 4>$Null
            
            If(!($?))
                                        {           {
                    Write-Warning "
                                                $cnt++                   `n
                    Unable to retrieve Policies information
                                                                   "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Policies information"
                    }
                                                If($cnt -eq 0)                   If($Text)
                                                {                   {
                                                        Line 3 "Handler`t`t`t`t`t: " $item                           Line 0 "Unable to retrieve Policies information"
                                                }                   }
                                                Else                   If($HTML)
                                                {                   {
                                                        Line 8 '  ' $item                           WriteHTMLLine 0 0 "Unable to retrieve Policies information"
                                                }                   }
                                        }           }
                                        $tmpArray = $Null           ElseIf($? -and $null -eq $Policies)
            {
                    Write-Host "
                    No Policies information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Policies information was found"
                                }                   }
                                Line 3 "Execute a notification script`t`t: " $RASNotificationHandler.ExecuteScript                   If($Text)
                                    
                                If($RASNotificationHandler.ExecuteScript)    
                                {                   {
                                        $results = Get-RASNotificationScript -id $RASNotificationHandler.ScriptId -EA 0 4>$Null                           Line 0 "No Policies information was found"
                                                           }
                                        If(!($?))                   If($HTML)
                                        {                   {
                                                $ScriptName = "Unable to retrieve script name"                           WriteHTMLLine 0 0 "No Policies information was found"
                                        }                   }
            }
                                        Else           Else
                                        {           {
                                                $ScriptName = $results.Name                   OutputPoliciesSummary $Policies
                    OutputPoliciesDetails $Policies
                                        }           }
                                            
                                        Line 8 '  ' $ScriptName    
                                        $ScriptName = $Null    
                                }   }
 
                                Line 3 "Notification handler grace period`t: " "$GracePeriod minutes" <> Function OutputPoliciesSectionPage
                                If($RASNotificationHandler.EnableInterval)   {
            If($MSWord -or $PDF)
                                {           {
                                        Line 3 "Notifications interval`t`t`t: " "$NotificationsInterval minutes"                   $Script:Selection.InsertNewPage()
                    WriteWordLine 1 0 "Policies"
                                }           }
            If($Text)
                                Else           {
                    Line 0 "Policies"
            }
            If($HTML)
                                {           {
                                        Line 3 'Send one notification and suspend further notifications until recovered'                   WriteHTMLLine 1 0 "Policies"
                                }           }
                        }   }
     
    Function OutputPoliciesSummary
    {
            Param([object] $Policies)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Policies Summary"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Policies"
            }
            If($Text)
            {
                        Line 0 ""                   Line 1 "Policies"
                }           }
                If($HTML)           If($HTML)
                {           {
                    WriteHTMLLine 2 0 "Policies"
            }
            
            ForEach($Policy in $Policies)
            {
                    $ClientOptions   = $Policy.ClientPolicy.ClientOptions
                    $ControlSettings = $Policy.ClientPolicy.ControlSettings
                    $Redirection     = $Policy.ClientPolicy.Redirection
                    $Session         = $Policy.ClientPolicy.Session
                        $rowdata = @()                   $Categories      = @()
                        $columnHeaders = @("Events",($Script:htmlsb),$RASNotificationText,$htmlwhite)                  
                        $rowdata += @(,("Enabled",($Script:htmlsb),$RASNotificationHandler.Enabled.ToString(),$htmlwhite))    
                        If($RASNotificationHandler.Enabled)                   If($Redirection.Enabled)
                        {                   {
                                $rowdata += @(,("Send email to RAS administrators",($Script:htmlsb),$RASNotificationHandler.SendEmail.ToString(),$htmlwhite))                           $Categories += "Redirection"
                    }
                                                  
                    If(     
                            $ControlSettings.ControlSettingsConnections.Enabled -or 
                            $ControlSettings.Password.Enabled -or 
                            $ControlSettings.ImportExport.Enabled)
                    {
                            $Categories += "Control settings"
                    }
                    
                    If( 
                            $ClientOptions.Connection.Enabled -or 
                            $ClientOptions.Logging.Enabled -or 
                            $ClientOptions.PCKeyboard.Enabled -or 
                            $ClientOptions.Update.Enabled -or 
                            $ClientOptions.SingleSignOn.Enabled -or 
                            $ClientOptions.Global.Enabled -or 
                            $ClientOptions.Language.Enabled -or 
                            $ClientOptions.Printing.Enabled -or 
                            $ClientOptions.WindowsClient.Enabled -or 
                            $ClientOptions.RemoteFxUsbRedirection.Enabled)
                    {
                            $Categories += "Client options"
                    }
                    
                    If( 
                            $Session.PrimaryConnection.Enabled -or          
                            $Session.SecondaryConnections.Enabled -or 
                            $Session.Reconnection.Enabled -or 
                            $Session.ComputerName.Enabled -or 
                            $Session.ConnectionAdvancedSettings.Enabled -or 
                                If($RASNotificationHandler.Recipients -eq "")                           $Session.WebAuthentication.Enabled -or
                            $Session.MultiFactorAuthentication.Enabled -or 
                            $Session.SessionPreLaunch.Enabled -or 
                            $Session.LocalProxyAddress.Enabled -or 
                            $Session.Settings.Enabled -or 
                            $Session.MultiMonitor.Enabled -or 
                            $Session.PublishedApplications.Enabled -or      
                            $Session.DesktopOptions.Enabled -or 
                            $Session.Browser.Enabled -or 
                            $Session.Printing.Enabled -or 
                            $Session.Scanning.Enabled -or 
                            $Session.Audio.Enabled -or 
                            $Session.Keyboard.Enabled -or 
                            $Session.Clipboard.Enabled -or 
                            $Session.DiskDrives.Enabled -or 
                            $Session.Devices.Enabled -or 
                            $Session.Ports.Enabled -or 
                            $Session.SmartCards.Enabled -or 
                            $Session.WindowsTouchInput.Enabled -or 
                            $Session.FileTransfer.Enabled -or 
                            $Session.Performance.Enabled -or 
                            $Session.Compression.Enabled -or 
                            $Session.Network.Enabled -or 
                            $Session.AdvancedSettings.Enabled -or   
                            $Session.ServerAuthentication.Enabled           
                    )
                                {                   {
                            $Categories += "Session"
                    }
     
                    If($MSWord -or $PDF)
                    {
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Name"; Value = $Policy.Name; }) > $Null
                            $ScriptInformation.Add(@{Data = "Enabled"; Value = $Policy.Enabled; }) > $Null
                            $ScriptInformation.Add(@{Data = "Version"; Value = $Policy.Version; }) > $Null
                            
                            If($Categories.Count -eq 0)
                            {
                                        $rowdata += @(,("Handler",($Script:htmlsb),"",$htmlwhite))                                   $ScriptInformation.Add(@{Data = "Category"; Value = ""; }) > $Null
                                }                           }
                            ElseIf($Categories.Count -eq 4)
                            {
                                    $ScriptInformation.Add(@{Data = "Category"; Value = "All Categories"; }) > $Null
                            }
                                Else                           Else
                                {                           {
                                        $tmpArray = $RASNotificationHandler.Recipients.Split(",").Split(";")    
                                            
                                        $cnt = -1                                   $cnt=-1
                                    
                                        ForEach($item in $tmpArray)                                   ForEach($Category in $Categories)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                                                          
                                                If($cnt -eq 0)                                           If($cnt -eq 0)
                                                {                                           {
                                                        $rowdata += @(,("Handler",($Script:htmlsb),$item,$htmlwhite))                                                   $ScriptInformation.Add(@{Data = "Category"; Value = $Category; }) > $Null
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))                                                   $ScriptInformation.Add(@{Data = ""; Value = $Category; }) > $Null
                                                }                                           }
                                        }                                   }
                                        $tmpArray = $Null    
                                }                           }
                            
                            $ScriptInformation.Add(@{Data = "Description"; Value = $Policy.Description; }) > $Null
                            $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Policy.AdminLastMod; }) > $Null
                            $ScriptInformation.Add(@{Data = "Modified on"; Value = $Policy.TimeLastMod.ToString(); }) > $Null
                            $ScriptInformation.Add(@{Data = "Created by"; Value = $Policy.AdminCreate; }) > $Null
                                $rowdata += @(,("Execute a notification script",($Script:htmlsb),$RASNotificationHandler.ExecuteScript.ToString(),$htmlwhite))                           $ScriptInformation.Add(@{Data = "Created on"; Value = $Policy.TimeCreate.ToString(); }) > $Null
                            $ScriptInformation.Add(@{Data = "ID"; Value = $Policy.Id; }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 125;
                            $Table.Columns.Item(2).Width = 175;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                    }
                    If($Text)
                    {
                            Line 2 "Name`t`t`t: " $Policy.Name
                            Line 2 "Enabled`t`t`t: " $Policy.Enabled
                            Line 2 "Version`t`t`t: " $Policy.Version
                            
                            If($Categories.Count -eq 0)
                            {
                                    Line 2 "Category`t`t: " ""
                            }
                            ElseIf($Categories.Count -eq 4)
                            {
                                    Line 2 "Category`t`t: " "All Categories"
                            }
                            Else
                            {
                                    $cnt=-1
 
                                If($RASNotificationHandler.ExecuteScript) <>                                 ForEach($Category in $Categories)
 
                                        $results = Get-RASNotificationScript -id $RASNotificationHandler.ScriptId -EA 0 4>$Null <>                                         $cnt++
 
                                        If(!($?)) <>                                         If($cnt -eq 0)
 
                                                $ScriptName = "Unable to retrieve script name" <>                                                 Line 2 "Category`t`t: " $Category
 
                                                $ScriptName = $results.Name <>                                                 Line 5 "  " $Category
 
  <>                                 }
                            }
                                                                  
                            Line 2 "Description`t`t: " $Policy.Description
                            Line 2 "Last modification by`t: " $Policy.AdminLastMod
                            Line 2 "Modified on`t`t: " $Policy.TimeLastMod.ToString()
                            Line 2 "Created by`t`t: " $Policy.AdminCreate
                            Line 2 "Created on`t`t: " $Policy.TimeCreate.ToString()
                            Line 2 "ID`t`t`t: " $Policy.Id
                            Line 0 ""
                    }
                    If($HTML)
                    {
                            $rowdata = @()
                            $columnHeaders = @("Name",($Script:htmlsb),$Policy.Name,$htmlwhite)
                            $rowdata += @(,("Enabled",($Script:htmlsb),$Policy.Enabled,$htmlwhite))
                            $rowdata += @(,("Version",($Script:htmlsb),$Policy.Version,$htmlwhite))
                            
                            If($Categories.Count -eq 0)
                            {
                                        $rowdata += @(,("",($Script:htmlsb),$ScriptName,$htmlwhite))                                   $rowdata += @(,("Category",($Script:htmlsb),"",$htmlwhite))
                                        $ScriptName = $Null    
                                }                           }
                            ElseIf($Categories.Count -eq 4)
                            {
                                $rowdata += @(,( "Notification handler grace period",($Script:htmlsb),"$GracePeriod minutes",$htmlwhite))                                   $rowdata += @(,("Category",($Script:htmlsb),"All Categories",$htmlwhite))
                                If($RASNotificationHandler.EnableInterval)                           }
                            Else
                            {
                                    $cnt=-1
                                    
                                    ForEach($Category in $Categories)
 
  <>                                         $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                        $rowdata += @(,("Notifications interval",($Script:htmlsb),"$NotificationsInterval minutes",$htmlwhite))                                                   $rowdata += @(,("Category",($Script:htmlsb),$Category,$htmlwhite))
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $rowdata += @(,("Send one notification and suspend further notifications until recovered",($Script:htmlsb),"",$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),$Category,$htmlwhite))
                                            }
 
  -+                         
                            $rowdata += @(,("Description",($Script:htmlsb),$Policy.Description,$htmlwhite))
                            $rowdata += @(,("Last modification by",($Script:htmlsb), $Policy.AdminLastMod,$htmlwhite))
                            $rowdata += @(,("Modified on",($Script:htmlsb), $Policy.TimeLastMod.ToString(),$htmlwhite))
                            $rowdata += @(,("Created by",($Script:htmlsb), $Policy.AdminCreate,$htmlwhite))
                            $rowdata += @(,("Created on",($Script:htmlsb), $Policy.TimeCreate.ToString(),$htmlwhite))
                            $rowdata += @(,("ID",($Script:htmlsb),$Policy.Id,$htmlwhite))
 
                        $columnWidths = @("200","225") <>                         $columnWidths = @("150","200")
 
Function OutputRASNotificationScripts <> Function OutputPoliciesDetails
 
        Param([object] $RASNotificationScripts) <>         Param([object] $Policies)
 
  -+         Write-Verbose "$(Get-Date -Format G): `t`tOutput Policy Properties"
            
 
                WriteWordLine 4 0 "Notification scripts" <>                 WriteWordLine 2 0 "Policy Properties"
 
                Line 2 "Notification scripts" <>                 Line 1 "Policy Properties"
 
                WriteHTMLLine 4 0 "Notification scripts" <>                 WriteHTMLLine 2 0 "Policy Properties"
 
        ForEach($RASNotificationScript in $RASNotificationScripts) <>         ForEach($Policy in $Policies)
 
  -+                 Write-Verbose "$(Get-Date -Format G): `t`t`tProcessing Policy $($Policy.Name)"
                    
                    <#$ClientOptions   = $Policy.ClientPolicy.ClientOptions
                    $ControlSettings = $Policy.ClientPolicy.ControlSettings
                    $Redirection     = $Policy.ClientPolicy.Redirection
                    $Session         = $Policy.ClientPolicy.Session#>
     
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tPolicy"
 
  -+                         WriteWordLine 3 0 "Policy $($Policy.Name)"
                            WriteWordLine 4 0 "Policy"
 
                        $ScriptInformation.Add(@{Data = "Script name"; Value = $RASNotificationScript.Name; }) > $Null <>                         $ScriptInformation.Add(@{Data = "Name"; Value = $Policy.Name; }) > $Null
                        $ScriptInformation.Add(@{Data = 'Command'; Value = $RASNotificationScript.Command; }) > $Null    
                        $ScriptInformation.Add(@{Data = 'Arguments'; Value = $RASNotificationScript.Arguments; }) > $Null    
                        $ScriptInformation.Add(@{Data = 'Initial directory'; Value = $RASNotificationScript.InitialDirectory; }) > $Null    
                        $ScriptInformation.Add(@{Data = 'User name'; Value = $RASNotificationScript.Username; }) > $Null                           $ScriptInformation.Add(@{Data = "Description"; Value = $Policy.Description; }) > $Null
 
  <>                         $Table.Columns.Item(1).Width = 125;
                            $Table.Columns.Item(2).Width = 175;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
     
                            WriteWordLine 4 0 "Apply policy to"
                            [System.Collections.Hashtable[]] $NameWordTable = @();
                            
                            ForEach($Item in $Policy.UsersGroups)
                            {
                                    $NameTableRowHash = @{
                                    Name = $Item.Account;
                                    Type = $Item.Type;
                                    SID  = $Item.Sid;
                                    }
                                    $NameWordTable += $NameTableRowHash;
                            }
     
                            If($NameWordTable.Count -gt 0)
                            {
                                    $Table = AddWordTable -Hashtable $NameWordTable `
                                    -Columns  Name,Type,SID `
                                    -Headers  "Name","Type","SID"`
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 9 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                        $Table.Columns.Item(1).Width = 200;                                   $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 50;
                                    $Table.Columns.Item(3).Width = 250;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                            }
 
  <>                         Line 2 "Policy $($Policy.Name)"
                            Line 0 ""
                            Line 2 "Policy"
                            Line 3 "Name`t   : " $Policy.Name
                        Line 3 "Script name`t`t`t: " $RASNotificationScript.Name                           Line 3 "Description: " $Policy.Description
                        Line 3 "Command`t`t`t`t: " $RASNotificationScript.Command                           Line 0 ""
                        Line 3 "Arguments`t`t`t: " $RASNotificationScript.Arguments    
                        Line 3 "Initial directory`t`t: " $RASNotificationScript.InitialDirectory                           Line 2 "Apply policy to"
                        Line 3 "User name`t`t`t: " $RASNotificationScript.Username                           Line 3 "Name                                      Type   SID                                               "
                            Line 3 "==================================================================================================="
                            #       1234567890123456789012345678901234567890SS12345SS12345678901234567890123456789012345678901234567890
                            
                            ForEach($Item in $Policy.UsersGroups)
                            {
                                    Line 3 ( "{0,-40}  {1,-5}  {2,-40}" -f `
                                    $Item.Account, $Item.Type, $Item.Sid)
                            }
 
  -+                         WriteHTMLLine 3 0 "Policy $($Policy.Name)"
 
                        $columnHeaders = @("Script name",($Script:htmlsb),$RASNotificationScript.Name,$htmlwhite) <>                         $columnHeaders = @("Name",($Script:htmlsb),$Policy.Name,$htmlwhite)
                        $rowdata += @(,("Command",($Script:htmlsb),$RASNotificationScript.Command,$htmlwhite))    
                        $rowdata += @(,("Arguments",($Script:htmlsb),$RASNotificationScript.Arguments,$htmlwhite))    
                        $rowdata += @(,("Initial directory",($Script:htmlsb),$RASNotificationScript.InitialDirectory,$htmlwhite))    
                        $rowdata += @(,("User name",($Script:htmlsb),$RASNotificationScript.Username,$htmlwhite))                           $rowdata += @(,("Description",($Script:htmlsb),$Policy.Description,$htmlwhite))
 
                        $columnWidths = @("200","225") <>                         $columnWidths = @("150","200")
 
  -+  
                            $rowdata = @()
     
                            ForEach($Item in $Policy.UsersGroups)
                            {
                                    $rowdata += @(,(
                                    $Item.Account,$htmlwhite,
                                    $Item.Type,$htmlwhite,
                                    $Item.Sid,$htmlwhite))
                            }
     
                            $columnHeaders = @(
                            "Name",($Script:htmlsb),
                            "Type",($Script:htmlsb),
                            "SID",($Script:htmlsb))
     
                            $msg = "Apply policy to"
                            $columnWidths = @("200","50","300")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
 
  <>  
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tPolicy/Criteria"
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tPolicy/Criteria/Gateway criteria"
     
                    $GatewayType = ""
                    Switch($Policy.GatewayRule)
                    {
                            "Any"                           {$GatewayType = "if Client is connected to any gateway"; Break}
                            "AnyGW"                         {$GatewayType = "if Client is connected to any gateway"; Break}
                            "Connected"                     {$GatewayType = "if Client is connected to one of the following gateways"; Break}
                            "ConnectedToGWs"        {$GatewayType = "if Client is connected to one of the following gateways"; Break}
                            "NotConnected"          {$GatewayType = "if Client is not connecteed to one of the following gateways"; Break}
                            "NotConnectedToGWs"     {$GatewayType = "if Client is not connecteed to one of the following gateways"; Break}
                            Default                         {$GatewayType = "Policy/Criteria/Gateway criteria type not found: $($Policy.GatewayRule)"; Break}
        }                   }
     
                    $MACType = ""
                    Switch($Policy.MACRule)
                    {
                            "AnyMAC"                        {$MACType = "to any MAC address"; Break}
                            "AllowedMACs"           {$MACType = "if the Client's MAC address is one of the following"; Break}
                            "NotAllowedMACs"        {$MACType = "if the Client's MAC address is not one of the following"; Break}
                            Default                         {$MACType = "Policy/Criteria/Mac address criteria type not found: $($Policy.MACRule)"; Break}
}                   }
     
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 4 0 "Criteria"
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Policy/Criteria/Gateway criteria/Apply policy"; Value = $GatewayType; }) > $Null
                            If($Policy.GatewayRule -ne "AnyGW")
                            {
                                    ForEach($Gateway in $Policy.GatewayList)
                                    {
                                            $ScriptInformation.Add(@{Data = ""; Value = $Gateway; }) > $Null
                                    }
                            }
                            
                            $ScriptInformation.Add(@{Data = "Policy/Criteria/MAC address criteria/Apply policy"; Value = $MACType; }) > $Null
                            If($Policy.MACRule -ne "AnyMAC")
                            {
                                    ForEach($MAC in $Policy.MACList)
                                    {
                                            $ScriptInformation.Add(@{Data = ""; Value = $MAC; }) > $Null
                                    }
                            }
     
                            $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/Windows"; Value = $Policy.AllowedOSes.Windows.ToString(); }) > $Null
                            $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/iOS"; Value = $Policy.AllowedOSes.iOS.ToString(); }) > $Null
                            $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/macOS"; Value = $Policy.AllowedOSes.Mac.ToString(); }) > $Null
                            $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/Android"; Value = $Policy.AllowedOSes.Android.ToString(); }) > $Null
                            $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/Chrome"; Value = $Policy.AllowedOSes.Chrome.ToString(); }) > $Null
                            $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/Linux"; Value = $Policy.AllowedOSes.Linux.ToString(); }) > $Null
                            $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/WebClient"; Value = $Policy.AllowedOSes.WebClient.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 300;
                            $Table.Columns.Item(2).Width = 200;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
#endregion                           WriteWordLine 0 0 ""
                    }
#region process licensing                   If($Text)
Function ProcessLicensing                   {
                            Line 2 "Criteria"
                            Line 0 ""
                            Line 3 "Policy/Criteria/Gateway criteria/Apply policy: " $GatewayType
                            If($Policy.GatewayRule -ne "AnyGW")
{                           {
        Write-Verbose "$(Get-Date -Format G): Processing Licensing"                                   ForEach($Gateway in $Policy.GatewayList)
                                    {
        $results = Get-RASLicenseDetails -EA 0 4>$Null                                           Line 7 "  " $Gateway
                                    }
                            }
                                  
                            Line 3 "Policy/Criteria/MAC address criteria/Apply policy: " $MACType
                            If($Policy.MACRule -ne "AnyMAC")
                            {
                                    ForEach($MAC in $Policy.MACList)
                                    {
                                            Line 7 "  " $MAC
                                    }
                            }
     
                            Line 3 "Policy/Criteria/Parallels client criteria/Windows: " $Policy.AllowedOSes.Windows.ToString()
                            Line 3 "Policy/Criteria/Parallels client criteria/iOS: " $Policy.AllowedOSes.iOS.ToString()
                            Line 3 "Policy/Criteria/Parallels client criteria/WebClient: " $Policy.AllowedOSes.WebClient.ToString()
                            Line 3 "Policy/Criteria/Parallels client criteria/macOS: " $Policy.AllowedOSes.Mac.ToString()
                            Line 3 "Policy/Criteria/Parallels client criteria/Android: " $Policy.AllowedOSes.Android.ToString()
                            Line 3 "Policy/Criteria/Parallels client criteria/Chrome: " $Policy.AllowedOSes.Chrome.ToString()
                            Line 3 "Policy/Criteria/Parallels client criteria/Linux: " $Policy.AllowedOSes.Linux.ToString()
                            Line 0 ""
                    }
        If(!($?))                   If($HTML)
        {                   {
                            $rowdata = @()
     
                            $columnHeaders = @("Policy/Criteria/Gateway criteria/Apply policy",($Script:htmlsb),$GatewayType,$htmlwhite)
                            If($Policy.GatewayRule -ne "AnyGW")
                            {
                                    ForEach($Gateway in $Policy.GatewayList)
                                    {
                                            $rowdata += @(,("",($Script:htmlsb),$Gateway,$htmlwhite))
                                    }
                            }
                            
                            $rowdata += @(,("Policy/Criteria/MAC address criteria/Apply policy",($Script:htmlsb),$MACType,$htmlwhite))
                            If($Policy.MACRule -ne "AnyMAC")
                            {
                                    ForEach($MAC in $Policy.MACList)
                                    {
                                            $rowdata += @(,("",($Script:htmlsb),$MAC,$htmlwhite))
                                    }
                            }
     
                            $rowdata += @(,("Policy/Criteria/Parallels client criteria/Windows",($Script:htmlsb),$Policy.AllowedOSes.Windows.ToString(),$htmlwhite))
                            $rowdata += @(,("Policy/Criteria/Parallels client criteria/iOS",($Script:htmlsb),$Policy.AllowedOSes.iOS.ToString(),$htmlwhite))
                            $rowdata += @(,("Policy/Criteria/Parallels client criteria/WebClient",($Script:htmlsb),$Policy.AllowedOSes.WebClient.ToString(),$htmlwhite))
                            $rowdata += @(,("Policy/Criteria/Parallels client criteria/macOS",($Script:htmlsb),$Policy.AllowedOSes.Mac.ToString(),$htmlwhite))
                            $rowdata += @(,("Policy/Criteria/Parallels client criteria/Android",($Script:htmlsb),$Policy.AllowedOSes.Android.ToString(),$htmlwhite))
                            $rowdata += @(,("Policy/Criteria/Parallels client criteria/Chrome",($Script:htmlsb),$Policy.AllowedOSes.Chrome.ToString(),$htmlwhite))
                            $rowdata += @(,("Policy/Criteria/Parallels client criteria/Linux",($Script:htmlsb),$Policy.AllowedOSes.Linux.ToString(),$htmlwhite))
                            
                Write-Warning "                           $msg = "Criteria"
                            $columnWidths = @("400","300")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                    }
                `n    
                    If($MSWord -or $PDF)
                    {
                            [System.Collections.Hashtable[]] $SettingsWordTable = @();
                    }
                    If($HTML)
                    {
                            $rowdata = @()
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession"
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection"
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Primary connection"
                Unable to retrieve licensing information                   If($Policy.ClientPolicy.Session.PrimaryConnection.Enabled)
                "                   {
                            $txt = "Session/Connection/Primary connection/Name"
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve licensing information"                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.PrimaryConnection.Name;
                }                                   }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.PrimaryConnection.Name,$htmlwhite))
                            }
                If($Text)                           If($Text)
                {                           {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.PrimaryConnection.Name
                            }
                            
                        Line 0 "Unable to retrieve licensing information"                           $txt = "Session/Connection/Primary connection/Login/Auto Login"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.PrimaryConnection.AutoLogin.ToString();
                }                                   }
                            }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve licensing information"                                   $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.PrimaryConnection.AutoLogin.ToString(),$htmlwhite))
                }                           }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.PrimaryConnection.AutoLogin.ToString()
        }                           }
        ElseIf($? -and $null -eq $results)                          
                            $AuthType = ""
                            Switch($Policy.ClientPolicy.Session.PrimaryConnection.AuthenticationType)
        {                           {
                                    "Credentials"   {$AuthType = "Credentials"; Break}
                                    "SingleSignOn"  {$AuthType = "Single Sign-On"; Break}
                                    "SmartCard"             {$AuthType = "Smart card"; Break}
                                    "Web"                   {$AuthType = "Web"; Break}
                                    Default                 {$AuthType = "Primary connection/Login/Authentication type not found: $($Policy.ClientPolicy.Session.PrimaryConnection.AuthenticationType)"; Break}
                            }
                            
                            $txt = "Session/Connection/Primary connection/Login/Authentication type"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $AuthType;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $AuthType,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $AuthType
                            }
     
                            If($Policy.ClientPolicy.Session.PrimaryConnection.AuthenticationType -eq "Credentials")
                            {
                Write-Warning "No licensing information was found"                                   $txt = "Session/Connection/Primary connection/Login/Save password"
                If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                {                                   {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.PrimaryConnection.SavePassword.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.PrimaryConnection.SavePassword.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.PrimaryConnection.SavePassword.ToString()
                                    }
     
                        WriteWordLine 0 0 "No licensing information was found"                                   $txt = "Session/Connection/Primary connection/Login/Domain"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.PrimaryConnection.Domain;
                }                                           }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.PrimaryConnection.Domain,$htmlwhite))
                                    }
                If($Text)                                   If($Text)
                {                                   {
                        Line 0 "No licensing information was found"                                           OutputPolicySetting $txt $Policy.ClientPolicy.Session.PrimaryConnection.Domain
                                    }
                            }
 
  <>                 
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Secondary connections"
                    If($Policy.ClientPolicy.Session.SecondaryConnections.Enabled)
                    {
                            $txt = "Session/Connection/Secondary connections/Secondary connections"
                            $cnt = 0
                            
                            ForEach($Item in $Policy.ClientPolicy.Session.SecondaryConnections.ConnectionList)
                            {
                                    $cnt++
                                    $GatewayMode = ""
                                    Switch($Item.Mode)
                                    {
                                            "DirectMode"            {$GatewayMode = "Direct Mode"; Break}
                                            "DirectSSLMode"         {$GatewayMode = "Direct SSL Mode"; Break}
                                            "GatewayMode"           {$GatewayMode = "Gateway Mode"; Break}
                                            "GatewaySSLMode"        {$GatewayMode = "Gateway SSL Mode"; Break}
                                            Default                         {$GatewayMode = "Secondary connections/Secondary connections/Mode not found: $($Item.Mode)"; Break}
                                    }
                    
                                    If($cnt -eq 1)
                                    {
                                            If($MSWord -or $PDF)
                                            {
                                                    $SettingsWordTable += @{
                                                    Text = $txt;
                                                    Value = "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())";
                                                    }
                                            }
                If($HTML)                                           If($HTML)
                {                                           {
                        WriteHTMLLine 0 0 "No licensing information was found"                                                   $rowdata += @(,(
                                                    $txt,$htmlbold,
                                                    "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())",$htmlwhite))
                }                                           }
                                            If($Text)
                                            {
                                                    OutputPolicySetting $txt "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())"
        }                                           }
                                    }
        Else                                   Else
        {                                   {
                OutputRASLicense $results                                           If($MSWord -or $PDF)
                                            {
                                                    $SettingsWordTable += @{
                                                    Text = "";
                                                    Value = "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())";
        }                                                   }
}                                           }
                                            If($HTML)
                                            {
Function OutputRASLicense                                                   $rowdata += @(,(
                                                    "",$htmlbold,
                                                    "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())",$htmlwhite))
                                            }
                                            If($Text)
{                                           {
        Param([object] $RASLicense)                                                   OutputPolicySetting "`t`t`t`t`t`t`t      " "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())"
                                            }
                                    }
                            }
                    }
                          
        Write-Verbose "$(Get-Date -Format G): `tOutput RAS License"                   Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Reconnection"
                    If($Policy.ClientPolicy.Session.Reconnection.Enabled)
                    {
                            $txt = "Session/Connection/Reconnection/Reconnection/Reconnect if connection is dropped"
        If($MSWord -or $PDF)                           If($MSWord -or $PDF)
        {                           {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Reconnection.EnableReconnection.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Reconnection.EnableReconnection.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Reconnection.EnableReconnection.ToString()
                            }
                            
                            $txt = "Session/Connection/Reconnection/Reconnection/Connection retries"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Reconnection.ConnectionRetries.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Reconnection.ConnectionRetries.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Reconnection.ConnectionRetries.ToString()
                            }
                            
                            $txt = "Session/Connection/Reconnection/Connection banner/Show if reconnection is not established within (seconds)"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Reconnection.ConnectionBannerDelay.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Reconnection.ConnectionBannerDelay.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Reconnection.ConnectionBannerDelay.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Computer name"
                $Script:Selection.InsertNewPage()                   If($Policy.ClientPolicy.Session.ComputerName.Enabled)
                WriteWordLine 1 0 "License details"                   {
                            $txt = "Session/Connection/Computer name/Computer name/Override computer name"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                $ScriptInformation = New-Object System.Collections.ArrayList                                   Value = $Policy.ClientPolicy.Session.ComputerName.OverrideComputerName;
        }                                   }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.ComputerName.OverrideComputerName,$htmlwhite))
                            }
        If($Text)                           If($Text)
        {                           {
                Line 0 "License details"                                   OutputPolicySetting $txt $Policy.ClientPolicy.Session.ComputerName.OverrideComputerName
        }                           }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Advanced settings"
                    If($Policy.ClientPolicy.Session.ConnectionAdvancedSettings.Enabled)
                    {
                            $txt = "Session/Connection/Advanced settings/Connection/Connection timeout (seconds)"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionTimeout.ToString();
                                    }
                            }
        If($HTML)                           If($HTML)
        {                           {
                WriteHTMLLine 1 0 "License details"                                   $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionTimeout.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionTimeout.ToString()
                            }
                            
                            $txt = "Session/Connection/Advanced settings/Connection banner/Show if connection is not established within (seconds)"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionBannerDelay.ToString();
                                    }
                            }
                            If($HTML)
                            {
                $rowdata = @()                                   $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionBannerDelay.ToString(),$htmlwhite))
        }                           }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ConnectionBannerDelay.ToString()
                            }
                            
                            $txt = "Session/Connection/Advanced settings/Desktop/Show if published application does not start within (seconds)"
        If($MSWord -or $PDF)                           If($MSWord -or $PDF)
        {                           {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                $ScriptInformation.Add(@{Data = "License Type"; Value = $RASLicense.LicenseType; }) > $Null                                   Value = $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ShowDesktopTimeout.ToString();
                If(ValidObject $RASLicense LicenseKey)                                   }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ShowDesktopTimeout.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.ConnectionAdvancedSettings.ShowDesktopTimeout.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Web authentication"
                    If($Policy.ClientPolicy.Session.WebAuthentication.Enabled)
 
  <>                         $txt = "Session/Connection/Web authentication/Web authentication/Use default OS browser"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                        $ScriptInformation.Add(@{Data = "License Key"; Value = $RASLicense.LicenseKey; }) > $Null                                   Value = $Policy.ClientPolicy.Session.WebAuthentication.DefaultOsBrowser.ToString();
                }                                   }
                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null                           }
                If(ValidObject $RASLicense SupportExpireDate)                           If($HTML)
                {                           {
                        $ScriptInformation.Add(@{Data = "Support Expiration Date"; Value = $RASLicense.SupportExpireDate; }) > $Null                                   $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.WebAuthentication.DefaultOsBrowser.ToString(),$htmlwhite))
                }                           }
                If(ValidObject $RASLicense ExpiryDate)                           If($Text)
                {                           {
                        $ScriptInformation.Add(@{Data = "Expiration Date"; Value = $RASLicense.ExpiryDate; }) > $Null                                   OutputPolicySetting $txt $Policy.ClientPolicy.Session.WebAuthentication.DefaultOsBrowser.ToString()
                            }
                            
                            If($Policy.ClientPolicy.Session.WebAuthentication.DefaultOsBrowser -eq $False)
                            {
                                    $txt = "Session/Connection/Web authentication/Web authentication/Open browser window to complete log out"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.WebAuthentication.OpenBrowserOnLogout.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.WebAuthentication.OpenBrowserOnLogout.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.WebAuthentication.OpenBrowserOnLogout.ToString()
                                    }
                            }
 
                If(ValidObject $RASLicense LicenseFirstActive) <>                
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Multifactor authentication"
                    If($Policy.ClientPolicy.Session.MultiFactorAuthentication.Enabled)
 
  <>                         $txt = "Session/Connection/Multifactor authentication/Multifactor authentication/Remember last used method"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                        $ScriptInformation.Add(@{Data = "First Activation"; Value = $RASLicense.LicenseFirstActive; }) > $Null                                   Value = $Policy.ClientPolicy.Session.MultiFactorAuthentication.RememberLastUsedMethod.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.MultiFactorAuthentication.RememberLastUsedMethod.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.MultiFactorAuthentication.RememberLastUsedMethod.ToString()
                            }
 
  <>                 
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Session prelaunch"
                    If($Policy.ClientPolicy.Session.SessionPreLaunch.Enabled)
                    {
                            $SPMode = ""
                            Switch($Policy.ClientPolicy.Session.SessionPreLaunch.PreLaunchMode)
                            {
                                    "Off"                           {$SPMode = "Off"; Break}
                                    "Basic"                         {$SPMode = "Basic"; Break}
                                    "MachineLearning"       {$SPMode = "Machine Learning"; Break}
                $ScriptInformation.Add(@{Data = 'Maximum allowed concurrent users'; Value = $RASLicense.InstalledUsers; }) > $Null                                   Default                         {$SPMode = "Connection/Session prelaunch mode not found: $($Policy.ClientPolicy.Session.SessionPreLaunch.PreLaunchMode)"; Break}
                $ScriptInformation.Add(@{Data = 'Peak Users'; Value = $RASLicense.UsersPeak; }) > $Null                           }
     
                            $txt = "Session/Connection/Session prelaunch/Session prelaunch/Mode"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $SPMode;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $SPMode,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $SPMode
                            }
                            
                            $txt = "Session/Connection/Session prelaunch/Session prelaunch/Exclude sessions prelaunch"
                            $cnt = 0
                            
                $ScriptInformation.Add(@{Data = 'Concurrent Users'; Value = $RASLicense.UsersLicenseInfo; }) > $Null                           ForEach($Item in $Policy.ClientPolicy.Session.SessionPreLaunch.PreLaunchExclude)
                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null                           {
                                    $cnt++
                                    $TmpArray = $Item.Split(":")
                                    $Day      = $TmpArray[0].ToString()
                                    $MonthNum = $TmpArray[1]
                                    
                                    Switch($MonthNum)
                                    {
                                            1               {$Month = "January"; Break}
                                            2               {$Month = "February"; Break}
                                            3               {$Month = "March"; Break}
                                            4               {$Month = "April"; Break}
                                            5               {$Month = "May"; Break}
                                            6               {$Month = "June"; Break}
                                            7               {$Month = "July"; Break}
                                            8               {$Month = "August"; Break}
                                            9               {$Month = "September"; Break}
                                            10              {$Month = "October"; Break}
                                            11              {$Month = "November"; Break}
                                            12              {$Month = "December"; Break}
                                            Default {$Month = "Exclude sessions prelaunch Month not founf: $($MonthNum)"; Break}
                                    }
                                    
                                    If($cnt -eq 1)
                                    {
                                            If($MSWord -or $PDF)
                                            {
                                                    $SettingsWordTable += @{
                                                    Text = $txt;
                                                    Value = "Day: $Day   Month: $Month";
                                                    }
                                            }
                                            If($HTML)
                                            {
                                                    $rowdata += @(,(
                                                    $txt,$htmlbold,
                                                    "Day: $Day   Month: $Month",$htmlwhite))
                                            }
                                            If($Text)
                                            {
                                                    OutputPolicySetting $txt "Day: $Day   Month: $Month"
                                            }
                                    }
                                    Else
                                    {
                                            If($MSWord -or $PDF)
                                            {
                                                    $SettingsWordTable += @{
                                                    Text = "";
                                                    Value = "Day: $Day   Month: $Month";
                                                    }
                                            }
                                            If($HTML)
                                            {
                                                    $rowdata += @(,(
                                                    "",$htmlbold,
                                                    "Day: $Day   Month: $Month",$htmlwhite))
                                            }
                                            If($Text)
                                            {
                                                    OutputPolicySetting "`t`t`t`t`t`t`t`t`t`t " "Day: $Day   Month: $Month"
                                            }
                                    }
                                    
                            }
                            
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Connection/Local proxy address"
                If(ValidObject $RASLicense PAUserEmail)                   If($Policy.ClientPolicy.Session.LocalProxyAddress.Enabled)
 
  <>                         $txt = "Session/Connection/Local proxy address/Local proxy address/Use 127.0.0.1 IP address when using Gateway mode in VPN scenarios"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                        $ScriptInformation.Add(@{Data = 'Parallels Account user email'; Value = $RASLicense.PAUserEmail; }) > $Null                                   Value = $Policy.ClientPolicy.Session.LocalProxyAddress.UseLocalHostProxyIP.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.LocalProxyAddress.UseLocalHostProxyIP.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.LocalProxyAddress.UseLocalHostProxyIP.ToString()
                            }
 
                If(ValidObject $RASLicense PAUserName) <>                
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display"
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display/Settings"
                    If($Policy.ClientPolicy.Session.Settings.Enabled)
 
  <>                         $GAMode = ""
                            Switch($Policy.ClientPolicy.Session.Settings.GraphicsAcceleration)
                            {
                                    "AVCAdaptive"           {$GAMode = "AVC Adaptive"; Break}
                                    "Basic"                         {$GAMode = "Basic"; Break}
                                    "None"                          {$GAMode = "None"; Break}
                                    "RemoteFx"                      {$GAMode = "RemoteFX (default, forces 32-bit color depth)"; Break}
                                    "RemoteFxAdaptive"      {$GAMode = "RemoteFx Adaptive"; Break}
                        $ScriptInformation.Add(@{Data = 'Parallels Account user name'; Value = $RASLicense.PAUserName; }) > $Null                                   Default                         {$GAMode = "Display settings/Acceleration mode not found: $($Policy.ClientPolicy.Session.Settings.GraphicsAcceleration)"; Break}
                            }
     
                            $txt = "Session/Display/Settings/Display settings/Acceleration mode"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $GAMode;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $GAMode,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $GAMode
                            }
                            
                            $ColorDepth = ""
                            Switch($Policy.ClientPolicy.Session.Settings.ColorDepths)
                            {
                                    "Colors256"                             {$ColorDepth = "256 Colors"; Break}
                                    "HighColor15Bit"                {$ColorDepth = "High Color (15 bit)"; Break}
                                    "HighColor16Bit"                {$ColorDepth = "High Color (16 bit)"; Break}
                                    "TrueColor24Bit"                {$ColorDepth = "True Color (24 bit)"; Break}
                                    "HighestQuality32Bit"   {$ColorDepth = "Highest Quality (32 bit)"; Break}
                                    Default                                 {$ColorDepth = "Display settings/Color depth not found: $($Policy.ClientPolicy.Session.Settings.ColorDepths)"; Break}
                            }
     
                            $txt = "Session/Display/Settings/Display settings/Color depth"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $ColorDepth;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $ColorDepth,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $ColorDepth
                            }
 
                If(ValidObject $RASLicense PACompanyName) <>  
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display/Multi-monitor"
                    If($Policy.ClientPolicy.Session.MultiMonitor.Enabled)
 
  <>                         $txt = "Session/Display/Multi-monitor/Multi-monitor/Use all monitors for desktop session (if applicable)"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.MultiMonitor.UseAllMonitors.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.MultiMonitor.UseAllMonitors.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.MultiMonitor.UseAllMonitors.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display/Published applications"
                    If($Policy.ClientPolicy.Session.PublishedApplications.Enabled)
                    {
                            $txt = "Session/Display/Published applications/Published applications/Use primary monitor only"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                        $ScriptInformation.Add(@{Data = 'Parallels Account company'; Value = $RASLicense.PACompanyName; }) > $Null                                   Value = $Policy.ClientPolicy.Session.PublishedApplications.UsePrimaryMonitor.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.PublishedApplications.UsePrimaryMonitor.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.PublishedApplications.UsePrimaryMonitor.ToString()
                            }
 
  <>                 
                $Table = AddWordTable -Hashtable $ScriptInformation `                   Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display/Desktop options"
                -Columns Data,Value `                   If($Policy.ClientPolicy.Session.DesktopOptions.Enabled)
                    {
                            $SmartSize = ""
                            Switch($Policy.ClientPolicy.Session.DesktopOptions.SmartSizing)
                            {
                                    "Disabled"      {$SmartSize = "Disabled"; Break}
                                    "Scale"         {$SmartSize = "Scale (fit to window)"; Break}
                                    "Resize"        {$SmartSize = "Resize (update resolution)"; Break}
                                    Default         {$SmartSize = "Desktop options/Smart-sizing not found: $($Policy.ClientPolicy.Session.DesktopOptions.SmartSizing)"; Break}
                            }
                -List `    
                            $txt = "Session/Display/Desktop options/Desktop options/Smart-sizing"
                            If($MSWord -or $PDF)
                            {
                -Format $wdTableGrid `                                   $SettingsWordTable += @{
                -AutoFit $wdAutoFitFixed;                                   Text = $txt;
                                    Value = $SmartSize;
                                    }
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite                           }
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                           If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $SmartSize,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $SmartSize
                            }
                            
                            $txt = "Session/Display/Desktop options/Desktop options/Embed desktop in launcher"
                            If($MSWord -or $PDF)
                            {
                $Table.Columns.Item(1).Width = 250;                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.DesktopOptions.EmbedDesktop.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.DesktopOptions.EmbedDesktop.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.DesktopOptions.EmbedDesktop.ToString()
                            }
     
                            $txt = "Session/Display/Desktop options/Desktop options/Span desktop across all monitors"
                            If($MSWord -or $PDF)
                            {
                $Table.Columns.Item(2).Width = 250;                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.DesktopOptions.SpanDesktops.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.DesktopOptions.SpanDesktops.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.DesktopOptions.SpanDesktops.ToString()
                            }
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                         $ConnBar = ""
                            Switch($Policy.ClientPolicy.Session.DesktopOptions.FullScreenBar)
                            {
                                    "DoNotShow"             {$ConnBar = "Do not show"; Break}
                                    "ShowPinned"    {$ConnBar = "Show pinned"; Break}
                                    "ShowUnPinned"  {$ConnBar = "Show unpinned"; Break}
                                    Default                 {$ConnBar = "Desktop options/Connection bar in full screen not found: $($Policy.ClientPolicy.Session.DesktopOptions.FullScreenBar)"; Break}
                            }
 
                FindWordDocumentEnd <>                         $txt = "Session/Display/Desktop options/Desktop options/Connection bar in full screen"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                $Table = $Null                                   Value = $ConnBar;
                WriteWordLine 0 0 ""                                   }
        }                           }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $ConnBar,$htmlwhite))
                            }
        If($Text)                           If($Text)
        {                           {
                Line 1 "License Type`t`t`t: " $RASLicense.LicenseType                                   OutputPolicySetting $txt $ConnBar
                            }
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Display/Browser"
                If(ValidObject $RASLicense LicenseKey)                   If($Policy.ClientPolicy.Session.Browser.Enabled)
 
                        Line 1 "License Key`t`t`t: " $RASLicense.LicenseKey <>                         $BrowserOpen = ""
                            Switch($Policy.ClientPolicy.Session.Browser.BrowserOpenIn)
                            {
                                    "SameTab"       {$BrowserOpen = "Same tab"; Break}
                                    "NewTab"        {$BrowserOpen = "New tab"; Break}
                                    Default         {$BrowserOpen = "Browser/Open applications in not found: $($Policy.ClientPolicy.Session.Browser.BrowserOpenIn)"; Break}
                }                           }
                Line 0 ""    
                If(ValidObject $RASLicense SupportExpireDate)                           $txt = "Session/Display/Browser/Browser/Open applications in"
                            If($MSWord -or $PDF)
                {                           {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $BrowserOpen;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $BrowserOpen,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $BrowserOpen
                            }
                    }
     
                        Line 1 "Support Expiration Date`t`t: " $RASLicense.SupportExpireDate                   Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Printing"
                    If($Policy.ClientPolicy.Session.Printing.Enabled)
                    {
                            $PrintTechUse = ""
                            Switch($Policy.ClientPolicy.Session.Printing.DefaultPrinterTech)
                            {
                                    "None"                                                                                  {$PrintTechUse = "None"; Break}
                                    "RasUniversalPrintingTechnology"                                {$PrintTechUse = "RAS Universal Printing technology"; Break}
                                    "MicrosoftBasicPrintingTechnology"                              {$PrintTechUse = "Microsoft basic Printing Redirection technology"; Break}
                                    "RasUniversalPrintingAndMsBasicTechnologies"    {$PrintTechUse = "RAS Universal Printing and MS Basic Redirection technologies"; Break}
                                    Default                                                                                 {$PrintTechUse = "Technology/Use not found: $($Policy.ClientPolicy.Session.Printing.DefaultPrinterTech)"; Break}
                }                           }
     
                            $txt = "Session/Printing/Technology/Use"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $PrintTechUse;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $PrintTechUse,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $PrintTechUse
                            }
     
                            If( $Policy.ClientPolicy.Session.Printing.DefaultPrinterTech -eq "RasUniversalPrintingTechnology" -or 
                                    $Policy.ClientPolicy.Session.Printing.DefaultPrinterTech -eq "RasUniversalPrintingAndMsBasicTechnologies" )
                            {
                                    $RedirectPrinters = ""
                                    Switch($Policy.ClientPolicy.Session.Printing.RedirectPrinters)
                                    {
                                            "All"                   {$RedirectPrinters = "All"; Break}
                                            "DefaultOnly"   {$RedirectPrinters = "Default only"; Break}
                                            "SpecificOnly"  {$RedirectPrinters = "Specific only"; Break}
                                            Default                 {$RedirectPrinters = "RAS Universal Printing/Redirect printers not found: $($Policy.ClientPolicy.Session.Printing.RedirectPrinters)"; Break}
                                    }
     
                                    $txt = "Session/Printing/RAS Universal Printing/Redirect printers"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                If(ValidObject $RASLicense ExpiryDate)                                           Value = $RedirectPrinters;
                                            }
                                    }
                                    If($HTML)
                {                                   {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $RedirectPrinters,$htmlwhite))
                                    }
                                    If($Text)
                                    {
                        Line 1 "Expiration Date`t`t`t: " $RASLicense.ExpiryDate                                           OutputPolicySetting $txt $RedirectPrinters
                }                                   }
                If(ValidObject $RASLicense LicenseFirstActive)                                  
                                    If($Policy.ClientPolicy.Session.Printing.RedirectPrinters -eq "SpecificOnly")
                {                                   {
                        Line 1 "First Activation`t`t: " $RASLicense.LicenseFirstActive                                           ForEach($Item in $Policy.ClientPolicy.Session.Printing.RedirectPrintersList)
                                            {
                                                    If($MSWord -or $PDF)
                                                    {
                                                            $SettingsWordTable += @{
                                                            Text = "";
                                                            Value = "Name: $($Item)";
                                                            }
                                                    }
                                                    If($HTML)
                                                    {
                                                            $rowdata += @(,(
                                                            "",$htmlbold,
                                                            "Name: $($Item)",$htmlwhite))
                                                    }
                                                    If($Text)
                                                    {
                                                            OutputPolicySetting "`t`t`t`t`t`t`t " "Name: $($Item)"
                                                    }
                                            }
                                    }
                            }
 
  <>                 
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Scanning"
                    If($Policy.ClientPolicy.Session.Scanning.Enabled)
                    {
                            $ScanTechUse = ""
                            Switch($Policy.ClientPolicy.Session.Scanning.ScanTech)
                            {
                                    "None"                  {$ScanTechUse = "None"; Break}
                                    "WIA"                   {$ScanTechUse = "WIA"; Break}
                                    "TWAIN"                 {$ScanTechUse = "TWAIN"; Break}
                                    "WIAandTWAIN"   {$ScanTechUse = "WIA and TWAIN"; Break}
                                    Default                 {$ScanTechUse = "Technology/Use not found: $($Policy.ClientPolicy.Session.Scanning.ScanTech)"; Break}
                            }
     
                            $txt = "Session/Scanning/Technology/Use"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $ScanTechUse;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $ScanTechUse,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $ScanTechUse
                            }
     
                            If( $Policy.ClientPolicy.Session.Scanning.ScanTech -ne "None" )
                            {
                                    $RedirectScanners = ""
                                    Switch($Policy.ClientPolicy.Session.Scanning.ScanRedirect)
                                    {
                                            "All"                   {$RedirectScanners = "All"; Break}
                                            "SpecificOnly"  {$RedirectScanners = "Specific only"; Break}
                                            Default                 {$RedirectScanners = "RAS Universal Scanning/Redirect scanners not found: $($Policy.ClientPolicy.Session.Scanning.ScanRedirect)"; Break}
                                    }
     
                Line 1 "Maximum allowed concurrent users: " $RASLicense.InstalledUsers                                   $txt = "Session/Printing/RAS Universal Scanning/Redirect scanners"
                Line 1 "Peak Users`t`t`t: " $RASLicense.UsersPeak                                   If($MSWord -or $PDF)
                Line 1 "Concurrent Users`t`t: " $RASLicense.UsersLicenseInfo    
                Line 0 ""                                   {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                If(ValidObject $RASLicense PAUserEmail)                                           Value = $RedirectScanners;
                                            }
                                    }
                                    If($HTML)
                {                                   {
                        Line 1 "Parallels Account user email`t: " $RASLicense.PAUserEmail                                           $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $RedirectScanners,$htmlwhite))
                }                                   }
                If(ValidObject $RASLicense PAUserName)                                   If($Text)
                {                                   {
                        Line 1 "Parallels Account user name`t: " $RASLicense.PAUserName                                           OutputPolicySetting $txt $RedirectScanners
                }                                   }
                If(ValidObject $RASLicense PACompanyName)                                  
                                    If($Policy.ClientPolicy.Session.Scanning.ScanRedirect -eq "SpecificOnly")
                {                                   {
                                            $ScannerArray = @()
                                            If($Policy.ClientPolicy.Session.Scanning.ScanTech -eq "WIA")
                                            {
                        Line 1 "Parallels Account company`t: " $RASLicense.PACompanyName                                                   $ScannerArray = $Policy.ClientPolicy.Session.Scanning.ScanListWia
                }                                           }
                                            Else
                                            {
                                                    $ScannerArray = $Policy.ClientPolicy.Session.Scanning.ScanListTwain
                                            }
                                            
                                            ForEach($Item in $ScannerArray)
                                            {
                                                    If($MSWord -or $PDF)
                                                    {
                                                            $SettingsWordTable += @{
                Line 0 ""                                                           Text = "";
                                                            Value = "Name: $($Item)";
        }                                                           }
                                                    }
        If($HTML)                                                   If($HTML)
        {                                                   {
                $columnHeaders = @("License Type",($Script:htmlsb),$RASLicense.LicenseType,$htmlwhite)                                                           $rowdata += @(,(
                                                            "",$htmlbold,
                                                            "Name: $($Item)",$htmlwhite))
                                                    }
                                                    If($Text)
                                                    {
                                                            OutputPolicySetting "`t`t`t`t`t`t`t " "Name: $($Item)"
                                                    }
                                            }
                                    }
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Audio"
                If(ValidObject $RASLicense LicenseKey)                   If($Policy.ClientPolicy.Session.Audio.Enabled)
 
                        $rowdata += @(,("License Key",($Script:htmlsb),$RASLicense.LicenseKey,$htmlwhite)) <>                         $AudioMode = ""
                            Switch($Policy.ClientPolicy.Session.Audio.AudioModes)
                            {
                                    "BringToThisComputer"   {$AudioMode = "Bring to this computer"; Break}
                                    "DoNotPlay"                             {$AudioMode = "Do not play"; Break}
                                    "LeaveAtRemoteComputer" {$AudioMode = "Leave at remote computer"; Break}
                                    Default                                 {$AudioMode = "Remote audio playback/Where not found: $($Policy.ClientPolicy.Session.Audio.AudioModes)"; Break}
                }                           }
                $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))    
                If(ValidObject $RASLicense SupportExpireDate)                           $txt = "Session/Audio/Remote audio playback/Where"
                            If($MSWord -or $PDF)
                {                           {
                        $rowdata += @(,("Support Expiration Date",($Script:htmlsb),$RASLicense.SupportExpireDate,$htmlwhite))                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $AudioMode;
                }                                   }
                $rowdata += @(,("Expiration Date",($Script:htmlsb),$RASLicense.ExpiryDate,$htmlwhite))                           }
                If(ValidObject $RASLicense ExpiryDate)                           If($HTML)
                {                           {
                        $rowdata += @(,("Expiration Date",($Script:htmlsb),$RASLicense.ExpiryDate,$htmlwhite))                                   $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $AudioMode,$htmlwhite))
                }                           }
                If(ValidObject $RASLicense LicenseFirstActive)                           If($Text)
                {                           {
                        $rowdata += @(,("First Activation",($Script:htmlsb),$RASLicense.LicenseFirstActive,$htmlwhite))                                   OutputPolicySetting $txt $AudioMode
                }                           }
     
                            $AudioQuality = ""
                            Switch($Policy.ClientPolicy.Session.Audio.AudioQuality)
                            {
                                    "AdjustDynamically"                     {$AudioQuality = "Dynamically adjust based on available bandwidth"; Break}
                                    "UseMediumQuality"                      {$AudioQuality = "Always use medium audio quality"; Break}
                                    "UseUncompressedQuality"        {$AudioQuality = "Always use uncompressed audio quality"; Break}
                                    Default                                         {$AudioQuality = "Remote audio playback/Quality not found: $($Policy.ClientPolicy.Session.Audio.AudioQuality)"; Break}
                            }
     
                            $txt = "Session/Audio/Remote audio playback/Quality"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $AudioQuality;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $AudioQuality,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $AudioQuality
                            }
     
                $rowdata += @(,("Maximum allowed concurrent users",($Script:htmlsb),$RASLicense.InstalledUsers,$htmlwhite))                           $txt = "Session/Audio/Remote audio recording/Enable recording (if applicable)"
                $rowdata += @(,("Peak Users",($Script:htmlsb),$RASLicense.UsersPeak,$htmlwhite))                           If($MSWord -or $PDF)
                $rowdata += @(,("Concurrent Users",($Script:htmlsb),$RASLicense.UsersLicenseInfo,$htmlwhite))                           {
                $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Audio.AudioRec.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Audio.AudioRec.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Audio.AudioRec.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Keyboard"
                If(ValidObject $RASLicense PAUserEmail)                   If($Policy.ClientPolicy.Session.Keyboard.Enabled)
 
                        $rowdata += @(,("Parallels Account user email",($Script:htmlsb),$RASLicense.PAUserEmail,$htmlwhite)) <>                         $KeyboardWindow = ""
                            Switch($Policy.ClientPolicy.Session.Keyboard.KeyboardWindow)
                            {
                                    "LocalComputer"         {$KeyboardWindow = "On the local computer"; Break}
                                    "RemoteComputer"        {$KeyboardWindow = "On the remote computer"; Break}
                                    "FullScreenMode"        {$KeyboardWindow = "In full screen mode only"; Break}
                                    Default                         {$KeyboardWindow = "Keyboard/Apply Windows key combinations for desktops only not found: $($Policy.ClientPolicy.Session.Keyboard.KeyboardWindow)"; Break}
                }                           }
                If(ValidObject $RASLicense PAUserName)    
                            $txt = "Session/Keyboard/Keyboard/Apply Windows key combinations for desktops only"
                            If($MSWord -or $PDF)
                {                           {
                        $rowdata += @(,("Parallels Account user name",($Script:htmlsb),$RASLicense.PAUserName,$htmlwhite))                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $KeyboardWindow;
                }                                   }
                If(ValidObject $RASLicense PACompanyName)                           }
                            If($HTML)
                {                           {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $KeyboardWindow,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $KeyboardWindow
                            }
     
                            $txt = "Session/Keyboard/Keyboard/Send Unicode characters"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Keyboard.SendUnicodeChars.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                        $rowdata += @(,("Parallels Account company",($Script:htmlsb),$RASLicense.PACompanyName,$htmlwhite))                                   $Policy.ClientPolicy.Session.Keyboard.SendUnicodeChars.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Keyboard.SendUnicodeChars.ToString()
                            }
 
  <>                 
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources"
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Clipboard"
                    If($Policy.ClientPolicy.Session.Clipboard.Enabled)
                    {
                            $ClipboardRedir = ""
                            Switch($Policy.ClientPolicy.Session.Clipboard.ClipboardDirection)
                            {
                                    "ClientToServer"        {$ClipboardRedir = "Client to server only"; Break}
                                    "ServerToClient"        {$ClipboardRedir = "Server to client only"; Break}
                                    "Bidirectional"         {$ClipboardRedir = "Bidirectional"; Break}
                                    "None"                          {$ClipboardRedir = "Disabled"; Break}
                                    Default                         {$ClipboardRedir = "Clipboard/Clipboard redirection not found: $($Policy.ClientPolicy.Session.Clipboard.ClipboardDirection)"; Break}
                            }
                $msg = ""    
                $columnWidths = @("200","175")                           $txt = "Session/Local devices and resources/Clipboard/Clipboard/Clipboard redirection"
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                           If($MSWord -or $PDF)
                WriteHTMLLine 0 0 ""                           {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $ClipboardRedir;
        }                                   }
}                           }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $ClipboardRedir,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $ClipboardRedir
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Disk drives and folders"
                    If($Policy.ClientPolicy.Session.DiskDrives.Enabled)
                    {
                            $txt = "Session/Local devices and resources/Disk drives and folders/Disk drives and folders/Allow disk drives redirection"
                            If($MSWord -or $PDF)
                            {
#endregion                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.DiskDrives.RedirectDrives.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.DiskDrives.RedirectDrives.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.DiskDrives.RedirectDrives.ToString()
                            }
 
#region script core <>                         $txt = "Session/Local devices and resources/Disk drives and folders/Disk drives and folders/Use all disk drives available"
                            If($MSWord -or $PDF)
                            {
#Script begins                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.DiskDrives.UseAllDrives.ToString();
                                    }
ProcessScriptSetup                           }
                            If($HTML)
                            {
SetFilenames "Parallels_RAS"                                   $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.DiskDrives.UseAllDrives.ToString(),$htmlwhite))
                            }
ProcessFarm                           If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.DiskDrives.UseAllDrives.ToString()
                            }
 
  <>                         If($Policy.ClientPolicy.Session.DiskDrives.UseAllDrives)
                            {
                                    If($MSWord -or $PDF)
                                    {
GetFarmSites                                           $SettingsWordTable += @{
                                            Text = "";
                                            Value = "Drives A through Z";
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            "",$htmlbold,
                                            "Drives A through Z",$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting "`t`t`t`t`t`t`t`t`t`t`t   " "Drives A through Z"
                                    }
                            }
                            Else
                            {
                                    ForEach($Item in $Policy.ClientPolicy.Session.DiskDrives.RedirectToDrives)
                                    {
                                            If($MSWord -or $PDF)
                                            {
                                                    $SettingsWordTable += @{
                                                    Text = "";
$OnlyOneTIme = $True                                                   Value = $Item;
ForEach($Site in $Script:Sites)                                                   }
                                            }
                                            If($HTML)
{                                           {
                                                    $rowdata += @(,(
                                                    "",$htmlbold,
                                                    $Item,$htmlwhite))
                                            }
        If($OnlyOneTIme)                                           If($Text)
        {                                           {
                OutputFarmSite $Site                                                   OutputPolicySetting "`t`t`t`t`t`t`t`t`t`t`t  " $Item
                                            }
                                    }
                            }
     
                            $txt = "Session/Local devices and resources/Disk drives and folders/Disk drives and folders/Use also disk drives that I plug in later"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.DiskDrives.DynamicDrives.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.DiskDrives.DynamicDrives.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.DiskDrives.DynamicDrives.ToString()
                            }
                    }
 
                $OnlyOneTime = $False <>                 Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Devices"
                    If($Policy.ClientPolicy.Session.Devices.Enabled)
                    {
                            $txt = "Session/Local devices and resources/Devices/Devices/Allow devices redirection"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Devices.RedirectDevices.ToString();
        }                                   }
                            }
        OutputSite $Site                           If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Devices.RedirectDevices.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Devices.RedirectDevices.ToString()
                            }
 
  <>                         $txt = "Session/Local devices and resources/Devices/Devices/Use all devices available"
                            If($MSWord -or $PDF)
                            {
        ProcessLoadBalancing $Site                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Devices.UseAllDevices.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Devices.UseAllDevices.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Devices.UseAllDevices.ToString()
                            }
 
  <>                         $txt = "Session/Local devices and resources/Devices/Devices/Use also devices that I plug in later"
                            If($MSWord -or $PDF)
                            {
        ProcessPublishing $Site                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Devices.DynamicDevices.ToString();
                                    }
        ProcessUniversalPrinting $Site    
                            }
        ProcessUniversalScanning $Site                           If($HTML)
                            {
        ProcessConnection $Site                                   $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Devices.DynamicDevices.ToString(),$htmlwhite))
}                           }
                            If($Text)
                            {
ProcessPolicies #new in 18.1                                   OutputPolicySetting $txt $Policy.ClientPolicy.Session.Devices.DynamicDevices.ToString()
                            }
ProcessAdministration    
                    }
ProcessLicensing    
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Video capture devices"
#endregion                   #can't find
                    
#region finish script    
Write-Verbose "$(Get-Date -Format G): Finishing up document"                   Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Ports"
#end of document processing                   If($Policy.ClientPolicy.Session.Ports.Enabled)
                    {
If(($MSWORD -or $PDF) -and ($Script:CoverPagesExist))                           $txt = "Session/Local devices and resources/Ports/Allow LPT and COM ports redirection"
                            If($MSWord -or $PDF)
{                           {
        $AbstractTitle = "Parallels RAS Inventory Report"                                   $SettingsWordTable += @{
        $SubjectTitle = "Parallels RAS Inventory Report"                                   Text = $txt;
        UpdateDocumentProperties $AbstractTitle $SubjectTitle                                   Value = $Policy.ClientPolicy.Session.Ports.RedirectCOMPorts.ToString();
}                                   }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Ports.RedirectCOMPorts.ToString(),$htmlwhite))
                            }
If($ReportFooter)                           If($Text)
{                           {
        OutputReportFooter                                   OutputPolicySetting $txt $Policy.ClientPolicy.Session.Ports.RedirectCOMPorts.ToString()
}                           }
                    }
ProcessDocumentOutput "Regular"                  
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Smart cards"
                    If($Policy.ClientPolicy.Session.SmartCards.Enabled)
                    {
ProcessScriptEnd                           $txt = "Session/Local devices and resources/Smart cards/Allow smart cards redirection"
                            If($MSWord -or $PDF)
                            {
#endregion                                   $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.SmartCards.RedirectSmartCards.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.SmartCards.RedirectSmartCards.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.SmartCards.RedirectSmartCards.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Windows touch input"
                    If($Policy.ClientPolicy.Session.WindowsTouchInput.Enabled)
                    {
                            $txt = "Session/Local devices and resources/Windows touch input/Allow Windows touch input redirection"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.WindowsTouchInput.TouchInput.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.WindowsTouchInput.TouchInput.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.WindowsTouchInput.TouchInput.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/File transfer"
                    If($Policy.ClientPolicy.Session.FileTransfer.Enabled)
                    {
                            $FileTransfer = ""
                            Switch($Policy.ClientPolicy.Session.FileTransfer.FileTransferMode)
                            {
                                    "ClientToServer"        {$FileTransfer = "Client to server only"; Break}
                                    "ServerToClient"        {$FileTransfer = "Server to client only"; Break}
                                    "Bidirectional"         {$FileTransfer = "Bidirectional"; Break}
                                    "None"                          {$FileTransfer = "Disabled"; Break}
                                    Default                         {$FileTransfer = "File transfer/Allow file transfer mode not found: $($Policy.ClientPolicy.Session.FileTransfer.FileTransferMode)"; Break}
                            }
     
                            $txt = "Session/Local devices and resources/File transfer/Allow file transfer"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $FileTransfer;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $FileTransfer,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $FileTransfer
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Experience"
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Experience/Performance"
                    If($Policy.ClientPolicy.Session.Performance.Enabled)
                    {
                            $ConnSpeed = ""
                            Switch($Policy.ClientPolicy.Session.Performance.NetType)
                            {
                                    "Modem"                                                 {$ConnSpeed = "Modem (56Kbps)"; Break}
                                    "LowSpeedBroadband"                             {$ConnSpeed = "Low speed broadband (256 Kbps - 2 Mbps)"; Break}
                                    "Satellite"                                             {$ConnSpeed = "Satellite (2 Mbps - 16 Mbps with high latency)"; Break}
                                    "HighSpeedBroadband"                    {$ConnSpeed = "High speed broadband (2 Mbps - 16 Mbps)"; Break}
                                    "WAN"                                                   {$ConnSpeed = "WAN (10 Mbps or higher with high latency)"; Break}
                                    "LAN"                                                   {$ConnSpeed = "LAN (10 Mbps or higher)"; Break}
                                    "DetectConnectionQualityAuto"   {$ConnSpeed = "Detect connection quality automatically"; Break}
                                    Default                                                 {$ConnSpeed = "Performance/Choose your connection speed to optimize performance mode not found: $($Policy.ClientPolicy.Session.Performance.NetType)"; Break}
                            }
     
                            $txt = "Session/Experience/Performance/Performance/Choose your connection speed to optimize performance"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $ConnSpeed;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $ConnSpeed,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $ConnSpeed
                            }
     
                            If($Policy.ClientPolicy.Session.Performance.NetType -ne "DetectConnectionQualityAuto")
                            {
                                    $txt = "Session/Experience/Performance/Performance/Desktop backgroup"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.Performance.DesktopBackground.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.Performance.DesktopBackground.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.DesktopBackground.ToString()
                                    }
     
                                    $txt = "Session/Experience/Performance/Performance/Font smoothing"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.Performance.FontSmoothing.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.Performance.FontSmoothing.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.FontSmoothing.ToString()
                                    }
     
                                    $txt = "Session/Experience/Performance/Performance/Menu and window animation"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.Performance.WindowMenuAnimation.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.Performance.WindowMenuAnimation.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.WindowMenuAnimation.ToString()
                                    }
     
                                    $txt = "Session/Experience/Performance/Performance/Desktop composition"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.Performance.DesktopComposition.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.Performance.DesktopComposition.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.DesktopComposition.ToString()
                                    }
     
                                    <#$txt = "Session/Experience/Performance/Performance/Show contents of window while dragging"
                                    #This property is missing from $Policy.ClientPolicy.Session.Performance
                                    PS C:\Webster> $Policy.ClientPolicy.Session.Performance | fl *
     
                                    Enabled             : True
                                    NetType             : Satellite
                                    DesktopBackground   : True
                                    FontSmoothing       : True
                                    WindowMenuAnimation : True
                                    DesktopComposition  : True
                                    Themes              : True
                                    BitmapCaching       : True
                                    MoveSizeFullDrag    : True                              
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.Performance..ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.Performance..ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance..ToString()
                                    }#>
     
                                    $txt = "Session/Experience/Performance/Performance/Themes"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.Performance.Themes.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.Performance.Themes.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.Themes.ToString()
                                    }
     
                                    $txt = "Session/Experience/Performance/Performance/Bitmap caching"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.Performance.BitmapCaching.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.Performance.BitmapCaching.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.BitmapCaching.ToString()
                                    }
                            }
     
                            $txt = "Session/Experience/Performance/Performance/Optimize resizing/moving windows"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Performance.MoveSizeFullDrag.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Performance.MoveSizeFullDrag.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.MoveSizeFullDrag.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Experience/Compression"
                    If($Policy.ClientPolicy.Session.Compression.Enabled)
                    {
                            $txt = "Session/Experience/Compression/Choose your compress preferences to optimize performance"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Compression.Compress.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Compression.Compress.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Compression.Compress.ToString()
                            }
     
                            $txt = "Session/Experience/Compression/Enable RDP compression"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.Compression.Compress.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.Compression.Compress.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Compression.Compress.ToString()
                            }
     
                            $PrintCompression = ""
                            Switch($Policy.ClientPolicy.Session.Compression.PrintingCompression)
                            {
                                    "CompressionDisabled"           {$PrintCompression = "Compression disabled"; Break}
                                    "BestSpeed"                                     {$PrintCompression = "Best speed (uses less CPU)"; Break}
                                    "BestSize"                                      {$PrintCompression = "Best size (uses less network traffic)"; Break}
                                    "BasedOnConnectionSpeed"        {$PrintCompression = "Based on connection speed"; Break}
                                    Default                                         {$PrintCompression = "Universal printing compression policy not found: $($Policy.ClientPolicy.Session.Compression.PrintingCompression)"; Break}
                            }
     
                            $txt = "Session/Experience/Compression/Universal printing compression policy"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $PrintCompression;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $PrintCompression,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $PrintCompression
                            }
     
                            $ScanCompression = ""
                            Switch($Policy.ClientPolicy.Session.Compression.ScanningCompression)
                            {
                                    "CompressionDisabled"           {$ScanCompression = "Compression disabled"; Break}
                                    "BestSpeed"                                     {$ScanCompression = "Best speed (uses less CPU)"; Break}
                                    "BestSize"                                      {$ScanCompression = "Best size (uses less network traffic)"; Break}
                                    "BasedOnConnectionSpeed"        {$ScanCompression = "Based on connection speed"; Break}
                                    Default                                         {$ScanCompression = "Universal scanning compression policy not found: $($Policy.ClientPolicy.Session.Compression.ScanningCompression)"; Break}
                            }
     
                            $txt = "Session/Experience/Compression/Universal scanning compression policy"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $ScanCompression;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $ScanCompression,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $ScanCompression
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Network"
                    If($Policy.ClientPolicy.Session.Network.Enabled)
                    {
                            If($Policy.ClientPolicy.Session.Network.UseProxyServer)
                            {
                                    $txt = "Session/Network/Proxy settings/Use proxy server"
     
                                    $ProxyServer = ""
                                    Switch($Policy.ClientPolicy.Session.Network.ProxyType)
                                    {
                                            0       {$ProxyServer = "SOCKS4"; Break}
                                            1       {$ProxyServer = "SOCKS4A"; Break}
                                            2       {$ProxyServer = "SOCKS5"; Break}
                                            3       {$ProxyServer = "HTTP 1.1"; Break}
                                            Default {$ProxyServer = "Use proxy server type not found: $($Policy.ClientPolicy.Session.Network.ProxyType)"; Break}
                                    }
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $ProxyServer;
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $ProxyServer,$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $ProxyServer
                                    }
     
                                    $txt = "Session/Network/Proxy settings/Proxy Host"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.Network.ProxyHost;
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.Network.ProxyHost,$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.Network.ProxyHost
                                    }
     
                                    $txt = "Session/Network/Proxy settings/Port"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.Session.Network.ProxyPort.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.Session.Network.ProxyPort.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.Network.ProxyPort.ToString()
                                    }
                                    
                                    If($Policy.ClientPolicy.Session.Network.ProxyType -ge 2)
                                    {
                                            $txt = "Session/Network/Proxy authentication/Proxy requires authentication"
                                            If($MSWord -or $PDF)
                                            {
                                                    $SettingsWordTable += @{
                                                    Text = $txt;
                                                    Value = $Policy.ClientPolicy.Session.Network.ProxyAuthentication.ToString();
                                                    }
                                            }
                                            If($HTML)
                                            {
                                                    $rowdata += @(,(
                                                    $txt,$htmlbold,
                                                    $Policy.ClientPolicy.Session.Network.ProxyAuthentication.ToString(),$htmlwhite))
                                            }
                                            If($Text)
                                            {
                                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Network.ProxyAuthentication.ToString()
                                            }
                                            
                                            If($Policy.ClientPolicy.Session.Network.ProxyAuthentication)
                                            {
                                                    $txt = "Session/Network/Proxy authentication/Use user logon credentials"
                                                    If($MSWord -or $PDF)
                                                    {
                                                            $SettingsWordTable += @{
                                                            Text = $txt;
                                                            Value = $Policy.ClientPolicy.Session.Network.ProxyUseLogonCredentials.ToString();
                                                            }
                                                    }
                                                    If($HTML)
                                                    {
                                                            $rowdata += @(,(
                                                            $txt,$htmlbold,
                                                            $Policy.ClientPolicy.Session.Network.ProxyUseLogonCredentials.ToString(),$htmlwhite))
                                                    }
                                                    If($Text)
                                                    {
                                                            OutputPolicySetting $txt $Policy.ClientPolicy.Session.Network.ProxyUseLogonCredentials.ToString()
                                                    }
                                                    
                                                    If($Policy.ClientPolicy.Session.Network.ProxyUseLogonCredentials -eq $False)
                                                    {
                                                            $txt = "Session/Network/Proxy authentication/Username"
                                                            If($MSWord -or $PDF)
                                                            {
                                                                    $SettingsWordTable += @{
                                                                    Text = $txt;
                                                                    Value = $Policy.ClientPolicy.Session.Network.ProxyUsername;
                                                                    }
                                                            }
                                                            If($HTML)
                                                            {
                                                                    $rowdata += @(,(
                                                                    $txt,$htmlbold,
                                                                    $Policy.ClientPolicy.Session.Network.ProxyUsername,$htmlwhite))
                                                            }
                                                            If($Text)
                                                            {
                                                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.Network.ProxyUsername
                                                            }
                                                    }
                                            }
                                    }
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Server authentication"
                    If($Policy.ClientPolicy.Session.ServerAuthentication.Enabled)
                    {
                            $AuthFail = ""
                            Switch($Policy.ClientPolicy.Session.ServerAuthentication.SessionAuthFailureAction)
                            {
                                    "Connect"               {$AuthFail = "Connect"; Break}
                                    "Warn"                  {$AuthFail = "Warn"; Break}
                                    "DoNotConnect"  {$AuthFail = "Do not connect"; Break}
                                    Default                 {$AuthFail = "RD session host authentication/If authentication fails not found: $($Policy.ClientPolicy.Session.ServerAuthentication.SessionAuthFailureAction)"; Break}
                            }
     
                            $txt = "Session/Server authentication/RD session host authentication/If authentication fails"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $AuthFail;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $AuthFail,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $AuthFail
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Advanced settings"
                    If($Policy.ClientPolicy.Session.AdvancedSettings.Enabled)
                    {
                            $txt = "Session/Advanced settings/Use client system colors"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.UseClientColors.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.UseClientColors.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.UseClientColors.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Use client system settings (border size, fonts, etc)"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.UseClientSettings.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.UseClientSettings.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.UseClientSettings.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Create shortcuts configured on server"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.CreateShrtCut.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.CreateShrtCut.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.CreateShrtCut.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Register file extensions associated from the server"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.RegisterExt.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.RegisterExt.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.RegisterExt.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Redirect URLs to the client device"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.UrlRedirection.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.UrlRedirection.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.UrlRedirection.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Redirect MAILTO to the client device"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.MailRedirection.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.MailRedirection.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.MailRedirection.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Always ask for credentials when starting applications"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.CredAlwaysAsk.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.CredAlwaysAsk.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.CredAlwaysAsk.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Allow server to send commands to be executed by client"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.AllowSrvCmd.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.AllowSrvCmd.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.AllowSrvCmd.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Confirm Server commands before executing them"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.PromptSrvCmd.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.PromptSrvCmd.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.PromptSrvCmd.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Network Level Authentication"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.CredSSP.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.CredSSP.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.CredSSP.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Redirect POS devices"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.RedirPOS.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.RedirPOS.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.RedirPOS.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Use Pre Windows 2000 login format"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.Pre2000Cred.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.Pre2000Cred.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.Pre2000Cred.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Disable RDP-UDP for gateway connections"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.DisableRUDP.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.DisableRUDP.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.DisableRUDP.ToString()
                            }
     
                            $txt = "Session/Advanced settings/Do not show drive redirection dialog"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Session.AdvancedSettings.DoNotShowDriveRedirectionDlg.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Session.AdvancedSettings.DoNotShowDriveRedirectionDlg.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Session.AdvancedSettings.DoNotShowDriveRedirectionDlg.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options"
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Connection"
                    If($Policy.ClientPolicy.ClientOptions.Connection.Enabled)
                    {
                            $ConnBanner = ""
                            Switch($Policy.ClientPolicy.ClientOptions.Connection.ConnectionBannerType)
                            {
                                    "SplashWindow"                  {$ConnBanner = "Splash Window"; Break}
                                    "TaskBarToastWindow"    {$ConnBanner = "Taskbar Toast Window"; Break}
                                    "None"                                  {$ConnBanner = "None"; Break}
                                    Default                                 {$ConnBanner = "Connection/Connection banner not found: $($Policy.ClientPolicy.ClientOptions.Connection.ConnectionBannerType)"; Break}
                            }
     
                            $txt = "Client options/Connection/Connection/Connection banner"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $ConnBanner;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $ConnBanner,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $ConnBanner
                            }
                            
                            If($Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshFarms -eq $False)
                            {
                                    $txt = "Client options/Connection/Connection/Automatically refresh connected RAS connections every (minutes)"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshFarms.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshFarms.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshFarms.ToString()
                                    }
                            }
                            Else
                            {
                                    $txt = "Client options/Connection/Connection/Automatically refresh connected RAS connections every (minutes)"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshTime_Mins.ToString();
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshTime_Mins.ToString(),$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Connection.AutoRefreshTime_Mins.ToString()
                                    }
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Logging"
                    If($Policy.ClientPolicy.ClientOptions.Logging.Enabled)
                    {
                            $txt = "Client options/Logging/Logging/Log level"
     
                            $LogLevel = ""
                            Switch($Policy.ClientPolicy.ClientOptions.Logging.LogLevel)
                            {
                                    "Verbose"       {$LogLevel = "Verbose"; Break}
                                    "4"                     {$LogLevel = "Extended"; Break}
                                    "5"                     {$LogLevel = "Verbose"; Break}
                                    "Standard"      {$LogLevel = "Standard"; Break}
                                    "Extended"      {$LogLevel = "Extended"; Break}
                                    Default         {$LogLevel = "Logging/Log level not found: $($Policy.ClientPolicy.ClientOptions.Logging.LogLevel)"; Break}
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $LogLevel;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $LogLevel,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $LogLevel
                            }
                            
                            If($Policy.ClientPolicy.ClientOptions.Logging.LogLevel -ne "Standard")
                            {
                                    $LoggingDate = $Policy.ClientPolicy.ClientOptions.Logging.LoggingStartDateTime
                                    $LogDate     = ($LoggingDate.ToUniversalTime()).ToShortDateString()
                                    $LogTime     = ($LoggingDate.ToUniversalTime()).ToLongTimeString()
                                    $LogDuration = ""
                                    
                                    Switch($Policy.ClientPolicy.ClientOptions.Logging.LoggingDuration)
                                    {
                                            0               {$LogDuration = ""; Break}
                                            3600    {$LogDuration = "1 hour"; Break}
                                            10800   {$LogDuration = "3 hours"; Break}
                                            21600   {$LogDuration = "6 hours"; Break}
                                            43200   {$LogDuration = "12 hours"; Break}
                                            86400   {$LogDuration = "1 day"; Break}
                                            259200  {$LogDuration = "3 days"; Break}
                                            Default {$LogDuration = " not found: $($Policy.ClientPolicy.ClientOptions.Logging.LoggingDuration)"; Break}
                                    }
                            
                                    $txt = "Client options/Logging/Logging/Date"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $LogDate;
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $LogDate,$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $LogDate
                                    }
                                    
                                    
                                    $txt = "Client options/Logging/Logging/Start"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $LogTime;
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $LogTime,$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $LogTime
                                    }
                                    
                                    
                                    $txt = "Client options/Logging/Logging/Duration"
                                    If($MSWord -or $PDF)
                                    {
                                            $SettingsWordTable += @{
                                            Text = $txt;
                                            Value = $LogDuration;
                                            }
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            $txt,$htmlbold,
                                            $LogDuration,$htmlwhite))
                                    }
                                    If($Text)
                                    {
                                            OutputPolicySetting $txt $LogDuration
                                    }
                            }
     
                            $txt = "Client options/Logging/Logging/Allow view log"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Logging.AllowViewLog.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Logging.AllowViewLog.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Logging.AllowViewLog.ToString()
                            }
     
                            $txt = "Client options/Logging/Logging/Allow clear log"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Logging.AllowClearLog.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Logging.AllowClearLog.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Logging.AllowClearLog.ToString()
                            }
                            
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Update"
                    If($Policy.ClientPolicy.ClientOptions.Update.Enabled)
                    {
                            $txt = "Client options/Update/Update/Check for updates on startup"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Update.CheckForUpdateOnLaunch.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Update.CheckForUpdateOnLaunch.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Update.CheckForUpdateOnLaunch.ToString()
                            }
     
                            $txt = "Client options/Update/Client version management/Parallels Client"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Update.UpdateClientXmlUrl;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Update.UpdateClientXmlUrl,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Update.UpdateClientXmlUrl
                            }
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/PC keyboard"
                    If($Policy.ClientPolicy.ClientOptions.PCKeyboard.Enabled)
                    {
                            $txt = "Client options/PC keyboard/PC keyboard/Force use PC keyboard (if applicable)"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.PCKeyboard.ForcePCKeybd.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.PCKeyboard.ForcePCKeybd.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.PCKeyboard.ForcePCKeybd.ToString()
                            }
     
                            $KBLayout = ""
                            Switch($Policy.ClientPolicy.ClientOptions.PCKeyboard.PCKeybd)
                            {
                                    "ChineseSimplified"             {$KBLayout = "Chinese (Simplified)"     ; Break}
                                    "ChineseTraditional"    {$KBLayout = "Chinese (Traditional)"; Break}
                                    "Dutch"                                 {$KBLayout = "Dutch"                            ; Break}
                                    "EnglishUK"                             {$KBLayout = "English (UK)"                     ; Break}
                                    "EnglishUS"                             {$KBLayout = "English (US)"                     ; Break}
                                    "French"                                {$KBLayout = "French"                       ; Break}
                                    "FrenchCanada"                  {$KBLayout = "French (Canada)"          ; Break}
                                    "German"                                {$KBLayout = "German"                       ; Break}
                                    "Italian"                               {$KBLayout = "Italian"                      ; Break}
                                    "Japanese"                              {$KBLayout = "Japanese"                     ; Break}
                                    "Korean"                                {$KBLayout = "Korean"                       ; Break}
                                    "Maltese"                               {$KBLayout = "Maltese"                      ; Break}
                                    "NorwegianNynorsk"              {$KBLayout = "Norwegian (Nynorsk)"      ; Break}
                                    "PortugueseBrazil"              {$KBLayout = "Portuguese (Brazil)"      ; Break}
                                    "Portuguese"                    {$KBLayout = "Portuguese"                   ; Break}
                                    "Russian"                               {$KBLayout = "Russian"                      ; Break}
                                    "Spanish"                               {$KBLayout = "Spanish"                      ; Break}
                                    "Swedish"                               {$KBLayout = "Swedish"                      ; Break}
                                    Default                                 {$KBLayout = "PC keyboard/Keyboard layout not found: $($Policy.ClientPolicy.ClientOptions.PCKeyboard.PCKeybd)"; Break}
                            }
     
                            $txt = "Client options/PC keyboard/PC keyboard/Keyboard layout"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $KBLayout;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $KBLayout,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $KBLayout
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Single Sign-On"
                    If($Policy.ClientPolicy.ClientOptions.SingleSignOn.Enabled)
                    {
                            $txt = "Client options/Single Sign-On/Single sign-on/Force to wrap third party SSO component"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.SingleSignOn.ForceThirdPartySSO.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.SingleSignOn.ForceThirdPartySSO.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.SingleSignOn.ForceThirdPartySSO.ToString()
                            }
     
                            $txt = "Client options/Single Sign-On/Single sign-on/Third-party credentials provider GUID"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.SingleSignOn.SSOProvGUID;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.SingleSignOn.SSOProvGUID,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.SingleSignOn.SSOProvGUID
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced"
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced/Global"
                    If($Policy.ClientPolicy.ClientOptions.Global.Enabled)
                    {
                            $txt = "Client options/Advanced/Global/Always on top"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.AlwaysOnTop.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.AlwaysOnTop.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.AlwaysOnTop.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/Show connections tree"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.ShowFolders.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.ShowFolders.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.ShowFolders.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/Minimize to tray on close or escape"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.MinimizeToTrayOnClose.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.MinimizeToTrayOnClose.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.MinimizeToTrayOnClose.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/Enable graphic accelerator (Chrome client)"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.GraphicsAccel.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.GraphicsAccel.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.GraphicsAccel.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/Enable work area background (Chrome client)"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.ClientWorkAreaBackground.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.ClientWorkAreaBackground.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.ClientWorkAreaBackground.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/Do not warn if server certificate is not verified"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.SSLNoWarning.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.SSLNoWarning.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.SSLNoWarning.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/Swap mouse buttons"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.SwapMouse.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.SwapMouse.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.SwapMouse.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/DPI aware"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.DPIAware.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.DPIAware.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.DPIAware.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/Add RAS connection automatically when starting web or shortcut items"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.AutoAddFarm.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.AutoAddFarm.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.AutoAddFarm.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/Do not show prompt message for auto add RAS connection"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.DontPromptAutoAddFarm.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.DontPromptAutoAddFarm.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.DontPromptAutoAddFarm.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/Close error messages automatically"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.SuppErrMsgs.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.SuppErrMsgs.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.SuppErrMsgs.ToString()
                            }
     
                            $txt = "Client options/Advanced/Global/Clear session cookies on exit"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Global.ClearCookies.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Global.ClearCookies.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Global.ClearCookies.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced/Language"
                    If($Policy.ClientPolicy.ClientOptions.Language.Enabled)
                    {
                            $Lang = ""
                            Switch($Policy.ClientPolicy.ClientOptions.Language.Lang)
                            {
                                    "Default"                               {$Lang = "Default"                      ; Break}
                                    "English"                               {$Lang = "English"                      ; Break}
                                    "German"                                {$Lang = "German"                           ; Break}
                                    "Japanese"                              {$Lang = "Japanese"                         ; Break}
                                    "Russian"                               {$Lang = "Russian"                          ; Break}
                                    "French"                                {$Lang = "French"                           ; Break}
                                    "Spanish"                               {$Lang = "Spanish"                          ; Break}
                                    "Italian"                               {$Lang = "Italian"                          ; Break}
                                    "Portuguese"                    {$Lang = "Portuguese"               ; Break}
                                    "ChineseSimplified"             {$Lang = "Chinese (Simplified)" ; Break}
                                    "ChineseTraditional"    {$Lang = "Chinese (Traditional)"; Break}
                                    "Korean"                                {$Lang = "Korean"                           ; Break}
                                    "Dutch"                                 {$Lang = "Dutch"                                ; Break}
                                    Default                                 {$Lang = "Language/Advanced client options/Language not found: $($Policy.ClientPolicy.ClientOptions.PCKeyboard.PCKeybd)"; Break}
                            }
     
                            $txt = "Client options/Advanced/Language/Advanced client options/Language"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Lang;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Lang,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Lang
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced/Printing"
                    If($Policy.ClientPolicy.ClientOptions.Printing.Enabled)
                    {
                            $txt = "Client options/Advanced/Printing/Install missing fonts automatically"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintInstallFonts.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Printing.PrintInstallFonts.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintInstallFonts.ToString()
                            }
     
                            <#$txt = "Client options/Advanced/Printing/Redirect custom paper sizes when server preferences are selected"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintAddCustomPapers.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Printing.PrintAddCustomPapers.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintAddCustomPapers.ToString()
                            }#>
     
                            $txt = "Client options/Advanced/Printing/Raw printing support"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintRawSupport.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Printing.PrintRawSupport.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintRawSupport.ToString()
                            }
     
                            $txt = "Client options/Advanced/Printing/Convert non distributable fonts data to images"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Printing.AllowEMFRasterization.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Printing.AllowEMFRasterization.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.AllowEMFRasterization.ToString()
                            }
     
                            $txt = "Client options/Advanced/Printing/Cache printers hardware information"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintUseCache.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Printing.PrintUseCache.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintUseCache.ToString()
                            }
     
                            $txt = "Client options/Advanced/Printing/Refressh printer hardware information every 30 days"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintRefreshCache.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Printing.PrintRefreshCache.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintRefreshCache.ToString()
                            }
     
                            $txt = "Client options/Advanced/Printing/Cache RAS Universal Printing embedded fonts"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.Printing.PrintUseFontsCache.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.Printing.PrintUseFontsCache.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.Printing.PrintUseFontsCache.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced/Windows client"
                    If($Policy.ClientPolicy.ClientOptions.WindowsClient.Enabled)
                    {
                            $txt = "Client options/Advanced/Windows client/Advanced client options - Windows client/Hide Launcher when application is launched"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.WindowsClient.Autohide.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.WindowsClient.Autohide.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.WindowsClient.Autohide.ToString()
                            }
     
                            $txt = "Client options/Advanced/Windows client/Advanced client options - Windows client/Launch automatically at Windows startup"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.WindowsClient.AutoLaunch.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.WindowsClient.AutoLaunch.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.WindowsClient.AutoLaunch.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tClient options/Advanced/RemoteFX USB redirection"
                    If($Policy.ClientPolicy.ClientOptions.RemoteFxUsbRedirection.Enabled)
                    {
                            $txt = "Client options/Advanced/RemoteFX USB redirection/RemoteFX USB redirection"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ClientOptions.RemoteFxUsbRedirection.RemoteFXUSBRedir.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ClientOptions.RemoteFxUsbRedirection.RemoteFXUSBRedir.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ClientOptions.RemoteFxUsbRedirection.RemoteFXUSBRedir.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tControl settings"
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tControl settings/Connections"
                    If($Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.Enabled)
                    {
                            $txt = "Control settings/Connections/Connections/Prohibit adding of RAS connections"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewASXGConns.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewASXGConns.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewASXGConns.ToString()
                            }
     
                            $txt = "Control settings/Connections/Connections/Prohibit adding standard RDP connections"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewStdConns.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewStdConns.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ControlSettings.ControlSettingsConnections.DontAddNewStdConns.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tControl settings/Password"
                    If($Policy.ClientPolicy.ControlSettings.Password.Enabled)
                    {
                            $txt = "Control settings/Password/Password/Prohibit saving password"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ControlSettings.Password.DontSavePwds.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ControlSettings.Password.DontSavePwds.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ControlSettings.Password.DontSavePwds.ToString()
                            }
     
                            $txt = "Control settings/Password/Password/Prohibit changing password"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ControlSettings.Password.DontChangePwds.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ControlSettings.Password.DontChangePwds.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ControlSettings.Password.DontChangePwds.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tControl settings/Import and export"
                    If($Policy.ClientPolicy.ControlSettings.ImportExport.Enabled)
                    {
                            $txt = "Control settings/Import and export/Import and export/Prohibit import/export connection settings"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.ControlSettings.ImportExport.DontImportExport.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.ControlSettings.ImportExport.DontImportExport.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.ControlSettings.ImportExport.DontImportExport.ToString()
                            }
                    }
                    
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tRedirection"
                    If($Policy.ClientPolicy.Redirection.Enabled)
                    {
                            $txt = "Redirection/New gateway/Gateway address"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Redirection.Gateway;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Redirection.Gateway,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Redirection.Gateway
                            }
     
                            $ConnMode = ""
                            Switch($Policy.ClientPolicy.Redirection.Mode)
                            {
                                    "DirectMode"            {$ConnMode = "Direct Mode"; Break}
                                    "DirectSSLMode"         {$ConnMode = "Direct SSL Mode"; Break}
                                    "GatewayMode"           {$ConnMode = "Gateway Mode"; Break}
                                    "GatewaySSLMode"        {$ConnMode = "Gateway SSL Mode"; Break}
                                    Default                         {$ConnMode = "New gateway/Connection mode not found: $($Policy.ClientPolicy.Redirection.Mode)"; Break}
                            }
     
                            $txt = "Redirection/New gateway/Connection mode"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $ConnMode;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $ConnMode,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $ConnMode
                            }
     
                            $txt = "Redirection/New gateway/Port"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Redirection.ServerPort.ToString();
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Redirection.ServerPort.ToString(),$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Redirection.ServerPort.ToString()
                            }
     
                            $txt = "Redirection/New gateway/Alternative address"
                            If($MSWord -or $PDF)
                            {
                                    $SettingsWordTable += @{
                                    Text = $txt;
                                    Value = $Policy.ClientPolicy.Redirection.AltGateway;
                                    }
                            }
                            If($HTML)
                            {
                                    $rowdata += @(,(
                                    $txt,$htmlbold,
                                    $Policy.ClientPolicy.Redirection.AltGateway,$htmlwhite))
                            }
                            If($Text)
                            {
                                    OutputPolicySetting $txt $Policy.ClientPolicy.Redirection.AltGateway
                            }
                    }
     
                    If($MSWord -or $PDF)
                    {
                            If($SettingsWordTable.Count -gt 0) #don't process if array is empty
                            {
                                    WriteWordLine 4 0 "Properties"
                                    $Table = AddWordTable -Hashtable $SettingsWordTable `
                                    -Columns  Text,Value `
                                    -Headers  "Setting Key","Value"`
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 9 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 300;
                                    $Table.Columns.Item(2).Width = 200;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
                            }
                            Else
                            {
                                    WriteWordLine 0 1 "There are no policy properties"
                            }
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                    }
                    If($Text)
                    {
                            Line 0 ""
                    }
                    If($HTML)
                    {
                            If($rowdata.count -gt 0)
                            {
                                    $columnHeaders = @(
                                    'Setting Key',($script:htmlsb),
                                    'Value',($script:htmlsb))
     
                                    $msg = "Properties"
                                    $columnWidths = @("600","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
     
                    Write-Verbose "$(Get-Date -Format G): "
            }
    }
     
    Function OutputPolicySetting
    {
            Param([string] $outputText, [string] $outputData)
     
            If($outputText -ne "")
            {
                    $xLength = $outputText.Length
                    If($outputText.Substring($xLength-2,2) -ne ": ")
                    {
                            $outputText += ": "
                    }
            }
            Line 2 $outputText $outputData
    }
    #endregion
     
    #region process administration
    Function ProcessAdministration
    {
            Write-Verbose "$(Get-Date -Format G): Processing Administration"
            
            OutputAdministrationSectionPage
            
            Write-Verbose "$(Get-Date -Format G): `tProcessing Accounts"
            
            $results = Get-RASAdminAccount -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve administration information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve administration information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve administration information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve administration information"
                    }
            }
            ElseIf($? -and $null -eq $results)
            {
                    Write-Host "
                    No administration information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No administration information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No administration information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No administration information was found"
                    }
            }
            Else
            {
                    #make sure the results are sorted
                    $results = $results | Sort-Object Name
                    OutputRASAccounts $results
            }
     
            Write-Verbose "$(Get-Date -Format G): `tProcessing Features"
            
            $RASFeatures = Get-RASHelpdeskEmailSettings -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve features information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve features information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve features information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve features information"
                    }
            }
            ElseIf($? -and $null -eq $RASFeatures)
            {
                    Write-Host "
                    No features information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No features information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No features information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No features information was found"
                    }
            }
            Else
            {
                    OutputRASFeatures $RASFeatures
            }
     
            Write-Verbose "$(Get-Date -Format G): `tProcessing Settings"
            
            $GotRASSettings = $False
            $RASSettings = Get-RASSystemSettings -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve settings information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve settings information"
                    }
            }
            ElseIf($? -and $null -eq $RASsettings)
            {
                    Write-Host "
                    No settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No settings information was found"
                    }
            }
            Else
            {
                    $GotRASSettings = $True
                    OutputRASSettings $RASSettings
            }
     
            $RASProxySettings = Get-RASProxySettings -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Proxy settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Proxy settings information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Proxy settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Proxy settings information"
                    }
            }
            ElseIf($? -and $null -eq $RASProxySettings)
            {
                    Write-Host "
                    No Proxy settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Proxy settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No Proxy settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Proxy settings information was found"
                    }
            }
            Else
            {
                    OutputRASProxySettings $RASProxySettings
            }
     
            If($GotRASSettings)
            {
                    OutputRASMiscSettings $RASSettings
            }
            
            $RASMailboxSettings = Get-RASMailboxSettings -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve mailbox settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve mailbox settings information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve mailbox settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve mailbox settings information"
                    }
            }
            ElseIf($? -and $null -eq $RASMailboxSettings)
            {
                    Write-Host "
                    No mailbox settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No mailbox settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No mailbox settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No mailbox settings information was found"
                    }
            }
            Else
            {
                    OutputRASMailboxSettings $RASMailboxSettings
            }
            
            $RASReportingSettings = Get-RASReportingSettings -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Reporting settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Reporting settings information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Reporting settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Reporting settings information"
                    }
            }
            ElseIf($? -and $null -eq $RASReportingSettings)
            {
                    Write-Host "
                    No Reporting settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Reporting settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No Reporting settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Reporting settings information was found"
                    }
            }
            Else
            {
                    OutputRASReportingSettings $RASReportingSettings
            }
            
            $RASPerformanceMonitorSettings = Get-RASPerformanceMonitorSettings -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Performance Monitor settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Performance Monitor settings information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Performance Monitor settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Performance Monitor settings information"
                    }
            }
            ElseIf($? -and $null -eq $RASPerformanceMonitorSettings)
            {
                    Write-Host "
                    No Performance Monitor settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Performance Monitor settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No Performance Monitor settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Performance Monitor settings information was found"
                    }
            }
            Else
            {
                    OutputRASPerformanceMonitorSettings $RASPerformanceMonitorSettings
            }
    }
     
    Function OutputAdministrationSectionPage
    {
            If($MSWord -or $PDF)
            {
                    $Script:Selection.InsertNewPage()
                    WriteWordLine 1 0 "Administration"
            }
            If($Text)
            {
                    Line 0 "Administration"
            }
            If($HTML)
            {
                    WriteHTMLLine 1 0 "Administration"
            }
    }
     
    Function OutputRASAccounts
    {
            Param([object] $RASAccounts)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Accounts"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Accounts"
            }
            If($Text)
            {
                    Line 1 "Accounts"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Accounts"
            }
            
            ForEach($RASAccount in $RASAccounts)
            {
                    Switch ($RASAccount.Permissions)
                    {
                            "CustomAdmin"   {$RASAccountPermissions = "Custom administration"; Break}
                            "PowerAdmin"    {$RASAccountPermissions = "Power administration"; Break}
                            "RootAdmin"             {$RASAccountPermissions = "Root administration"; Break}
                            Default                 {$RASAccountPermissions = "Unable to determine Permissions: $($RASAccount.Permissions)"; Break}
                    }
     
                    Switch ($RASAccount.Type)
                    {
                            "Group"         {$RASAccountType = "Group"; Break}
                            "User"          {$RASAccountType = "User"; Break}
                            "UserGroup"     {$RASAccountType = "Group User"; Break}
                            Default         {$RASAccountType = "Unknown: $($RASAccount.Type)"; Break}
                    }
     
                    Switch ($RASAccount.Notify)
                    {
                            "Email"         {$RASAccountNotify = "Via email"; Break}
                            "None"          {$RASAccountNotify = "Don't receive"; Break}
                            Default         {$RASAccountNotify = "Unknown: $($RASAccount.Notify)"; Break}
                    }
     
                    If($MSWord -or $PDF)
                    {
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Group or user names"; Value = $RASAccount.Name; }) > $Null
                            $ScriptInformation.Add(@{Data = "Type"; Value = $RASAccountType; }) > $Null
                            $ScriptInformation.Add(@{Data = 'Permissions'; Value = $RASAccountPermissions; }) > $Null
                            $ScriptInformation.Add(@{Data = 'Receive system notifications'; Value = $RASAccountNotify; }) > $Null
                            $ScriptInformation.Add(@{Data = 'Email'; Value = $RASAccount.Email; }) > $Null
                            $ScriptInformation.Add(@{Data = 'Mobile'; Value = $RASAccount.Mobile; }) > $Null
                            $ScriptInformation.Add(@{Data = 'Group'; Value = $RASAccount.GroupName; }) > $Null
                            $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RASAccount.AdminLastMod; }) > $Null
                            $ScriptInformation.Add(@{Data = "Modified on"; Value = $RASAccount.TimeLastMod.ToString(); }) > $Null
                            $ScriptInformation.Add(@{Data = "Created by"; Value = $RASAccount.AdminCreate; }) > $Null
                            $ScriptInformation.Add(@{Data = "Created on"; Value = $RASAccount.TimeCreate.ToString(); }) > $Null
                            $ScriptInformation.Add(@{Data = "ID"; Value = $RASAccount.Id.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 250;
                            $Table.Columns.Item(2).Width = 250;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                    }
                    If($Text)
                    {
                            Line 2 "Group or user names`t`t: " $RASAccount.Name
                            Line 2 "Type`t`t`t`t: " $RASAccountType
                            Line 2 "Permissions`t`t`t: " $RASAccountPermissions
                            Line 2 "Receive system notifications`t: " $RASAccountNotify
                            Line 2 "Email`t`t`t`t: " $RASAccount.Email
                            Line 2 "Mobile`t`t`t`t: " $RASAccount.Mobile
                            Line 2 "Group`t`t`t`t: " $RASAccount.GroupName
                            Line 2 "Last modification by`t`t: " $RASAccount.AdminLastMod
                            Line 2 "Modified on`t`t`t: " $RASAccount.TimeLastMod.ToString()
                            Line 2 "Created by`t`t`t: " $RASAccount.AdminCreate
                            Line 2 "Created on`t`t`t: " $RASAccount.TimeCreate.ToString()
                            Line 2 "ID`t`t`t`t: " $RASAccount.Id.ToString()
                            Line 0 ""
                    }
                    If($HTML)
                    {
                            $rowdata = @()
                            $columnHeaders = @("Group or user names",($Script:htmlsb),$RASAccount.Name,$htmlwhite)
                            $rowdata += @(,("Type",($Script:htmlsb),$RASAccountType,$htmlwhite))
                            $rowdata += @(,("Permissions",($Script:htmlsb),$RASAccountPermissions,$htmlwhite))
                            $rowdata += @(,("Receive system notifications",($Script:htmlsb),$RASAccountNotify,$htmlwhite))
                            $rowdata += @(,("Email",($Script:htmlsb),$RASAccount.Email,$htmlwhite))
                            $rowdata += @(,("Mobile",($Script:htmlsb),$RASAccount.Mobile,$htmlwhite))
                            $rowdata += @(,("Group",($Script:htmlsb),$RASAccount.GroupName,$htmlwhite))
                            $rowdata += @(,("Last modification by",($Script:htmlsb), $RASAccount.AdminLastMod,$htmlwhite))
                            $rowdata += @(,("Modified on",($Script:htmlsb), $RASAccount.TimeLastMod.ToString(),$htmlwhite))
                            $rowdata += @(,("Created by",($Script:htmlsb), $RASAccount.AdminCreate,$htmlwhite))
                            $rowdata += @(,("Created on",($Script:htmlsb), $RASAccount.TimeCreate.ToString(),$htmlwhite))
                            $rowdata += @(,("ID",($Script:htmlsb),$RASAccount.Id.ToString(),$htmlwhite))
     
                            $msg = ""
                            $columnWidths = @("200","175")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                    }
            }
    }
     
    Function OutputRASFeatures
    {
            Param([object] $RASFeatures)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Features"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Features"
                    WriteWordLine 3 0 "Helpdesk"
            }
            If($Text)
            {
                    Line 1 "Features"
                    Line 2 "Helpdesk"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Features"
                    WriteHTMLLine 3 0 "Helpdesk"
            }
            
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Enable Helpdesk functionality in Parallels Client"; Value = $RASFeatures.HelpDeskEnabled; }) > $Null
                    $ScriptInformation.Add(@{Data = "Helpdesk email"; Value = $RASFeatures.HelpDeskEmail; }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 250;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 3 "Enable Helpdesk functionality in Parallels Client`t: " $RASFeatures.HelpDeskEnabled
                    Line 3 "Helpdesk email`t`t`t`t`t`t: " $RASFeatures.HelpDeskEmail
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @("Enable Helpdesk functionality in Parallels Client",($Script:htmlsb),$RASFeatures.HelpDeskEnabled.ToString(),$htmlwhite)
                    $rowdata += @(,("Helpdesk email",($Script:htmlsb),$RASFeatures.HelpDeskEmail,$htmlwhite))
     
                    $msg = ""
                    $columnWidths = @("250","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
     
    Function OutputRASSettings
    {
            Param([object] $RASSettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Settings"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Settings"
                    WriteWordLine 3 0 "Customer experience program"
            }
            If($Text)
            {
                    Line 1 "Settings"
                    Line 2 "Customer experience program"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Settings"
                    WriteHTMLLine 3 0 "Customer experience program"
            }
            
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Participate in the Customer Experience Program"; Value = $RASSettings.CEPEnabled.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 250;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 3 "Participate in the Customer Experience Program`t`t: " $RASSettings.CEPEnabled.ToString()
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @("Participate in the Customer Experience Program",($Script:htmlsb),$RASSettings.CEPEnabled.ToString(),$htmlwhite)
     
                    $msg = ""
                    $columnWidths = @("200","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
     
    Function OutputRASProxySettings
    {
            Param([object] $RASProxySettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput HTTP Proxy Settings"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "HTTP proxy settings"
            }
            If($Text)
            {
                    Line 2 "HTTP proxy settings"
            }
            If($HTML)
            {
                    WriteHTMLLine 3 0 "HTTP proxy settings"
            }
            
            If($MSWord -or $PDF)
            {
                    If($RASProxySettings.HttpProxyMode -eq "NoProxy")
                    {
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "No proxy server"; Value = ""; }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 250;
                            $Table.Columns.Item(2).Width = 250;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                    }
                    Else
                    {
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Manual HTTP proxy configuration"; Value = ""; }) > $Null
                            $ScriptInformation.Add(@{Data = "Address"; Value = $RASProxySettings.HttpProxyAddress; }) > $Null
                            $ScriptInformation.Add(@{Data = "Port"; Value = $RASProxySettings.HttpProxyPort; }) > $Null
                            $ScriptInformation.Add(@{Data = "User name"; Value = $RASProxySettings.HttpProxyUser; }) > $Null
                            $ScriptInformation.Add(@{Data = "Password"; Value = $RASProxySettings.HttpProxyPwd; }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 250;
                            $Table.Columns.Item(2).Width = 250;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                    }
            }
            If($Text)
            {
                    If($RASProxySettings.HttpProxyMode -eq "NoProxy")
                    {
                            Line 3 "No proxy server" 
                            Line 0 ""
                    }
                    Else
                    {
                            Line 3 "Manual HTTP proxy configuration" 
                            Line 3 "Address`t`t: " $RASProxySettings.HttpProxyAddress
                            Line 3 "Port`t`t: " $RASProxySettings.HttpProxyPort
                            Line 3 "User name`t: " $RASProxySettings.HttpProxyUser
                            Line 3 "Password`t: " $RASProxySettings.HttpProxyPwd
                            Line 0 ""
                    }
            }
            If($HTML)
            {
                    If($RASProxySettings.HttpProxyMode -eq "NoProxy")
                    {
                            $rowdata = @()
                            $columnHeaders = @("No proxy server",($Script:htmlsb),"",$htmlwhite)
     
                            $msg = ""
                            $columnWidths = @("200","175")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                    }
                    Else
                    {
                            $rowdata = @()
                            $columnHeaders = @("Manual HTTP proxy configuration",($Script:htmlsb),"",$htmlwhite)
                            $rowdata += @(,("Address",($Script:htmlsb),$RASProxySettings.HttpProxyAddress,$htmlwhite))
                            $rowdata += @(,("Port",($Script:htmlsb),$RASProxySettings.HttpProxyPort.ToString(),$htmlwhite))
                            $rowdata += @(,("User name",($Script:htmlsb),$RASProxySettings.HttpProxyUser,$htmlwhite))
                            $rowdata += @(,("Password",($Script:htmlsb),$RASProxySettings.HttpProxyPwd,$htmlwhite))
     
                            $msg = ""
                            $columnWidths = @("200","175")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                    }
            }
    }
     
    Function OutputRASMiscSettings
    {
            Param([object] $RASSettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Miscellaneous Settings"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "Miscellaneous"
            }
            If($Text)
            {
                    Line 2 "Miscellaneous"
            }
            If($HTML)
            {
                    WriteHTMLLine 3 0 "Miscellaneous"
            }
            
            Switch ($RASSettings.ResetIdleSessionAfterMins)
            {
                    0               {$RASSettingsResetIdleSessionAfterMins = "Never"; Break}
                    15              {$RASSettingsResetIdleSessionAfterMins = "15 minutes"; Break}
                    30              {$RASSettingsResetIdleSessionAfterMins = "30 minutes"; Break}
                    60              {$RASSettingsResetIdleSessionAfterMins = "1 hour"; Break}
                    180             {$RASSettingsResetIdleSessionAfterMins = "3 hours"; Break}
                    360             {$RASSettingsResetIdleSessionAfterMins = "6 hours"; Break}
                    720             {$RASSettingsResetIdleSessionAfterMins = "12 hours"; Break}
                    1440    {$RASSettingsResetIdleSessionAfterMins = "1 day"; Break}
                    Default {$RASSettingsResetIdleSessionAfterMins = "Unable to determine Console idle time: $($RASSettings.ResetIdleSessionAfterMins)"; Break}
            }
            
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Reset idle RAS Console session after"; Value = $RASSettingsResetIdleSessionAfterMins; }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 250;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 3 "Reset idle RAS Console session after`t`t`t: " $RASSettingsResetIdleSessionAfterMins
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @("Reset idle RAS Console session after",($Script:htmlsb),$RASSettingsResetIdleSessionAfterMins,$htmlwhite)
     
                    $msg = ""
                    $columnWidths = @("200","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
     
    Function OutputRASMailboxSettings
    {
            Param([object] $RASMailboxSettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Mailbox"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Mailbox"
                    WriteWordLine 3 0 "Mailbox configuration"
            }
            If($Text)
            {
                    Line 1 "Mailbox"
                    Line 2 "Mailbox configuration"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Mailbox"
                    WriteHTMLLine 3 0 "Mailbox configuration"
            }
            
            Switch ($RASMailboxSettings.UseTLS)
            {
                    "YesIfAvailable"        {$RASMailboxSettingsUseTLS = "Use TLS/SSL if available"; Break}
                    "Yes"                           {$RASMailboxSettingsUseTLS = "Use TLS/SSL"; Break}
                    "No"                            {$RASMailboxSettingsUseTLS = "Do not use"; Break}
                    "3"                                     {$RASMailboxSettingsUseTLS = "Use TLS 1.2 if available"; Break}
                    Default                         {$RASMailboxSettingsUseTLS = "Unable to determine TLS/SSL setting: $($RASMailboxSettings.UseTLS)"; Break}
            }
            
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Mail server"; Value = $RASMailboxSettings.SMTPServer; }) > $Null
                    $ScriptInformation.Add(@{Data = "TLS/SSL"; Value = $RASMailboxSettingsUseTLS; }) > $Null
                    $ScriptInformation.Add(@{Data = "SMTP server requires authentication"; Value = $RASMailboxSettings.RequireAuth; }) > $Null
                    If($RASMailboxSettings.RequireAuth)
                    {
                            $ScriptInformation.Add(@{Data = "Username"; Value = $RASMailboxSettings.Username; }) > $Null
                    }
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 250;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 3 "Mail server`t`t`t`t`t`t: " $RASMailboxSettings.SMTPServer
                    Line 3 "TLS/SSL`t`t`t`t`t`t`t: " $RASMailboxSettingsUseTLS
                    Line 3 "SMTP server requires authentication`t`t`t: " $RASMailboxSettings.RequireAuth
                    If($RASMailboxSettings.RequireAuth)
                    {
                            Line 3 "Username`t`t`t`t`t`t: " $RASMailboxSettings.Username
                    }
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @("Mail server",($Script:htmlsb),$RASMailboxSettings.SMTPServer,$htmlwhite)
                    $rowdata += @(,("TLS/SSL",($Script:htmlsb),$RASMailboxSettingsUseTLS,$htmlwhite))
                    $rowdata += @(,("SMTP server requires authentication",($Script:htmlsb),$RASMailboxSettings.RequireAuth.ToString(),$htmlwhite))
                    If($RASMailboxSettings.RequireAuth)
                    {
                            $rowdata += @(,("Username",($Script:htmlsb),$RASMailboxSettings.Username,$htmlwhite))
                    }
     
                    $msg = ""
                    $columnWidths = @("200","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
     
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "Sender information"
            }
            If($Text)
            {
                    Line 2 "Sender information"
            }
            If($HTML)
            {
                    WriteHTMLLine 3 0 "Sender information"
            }
            
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Email address"; Value = $RASMailboxSettings.SenderAddress; }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 250;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 3 "Email address`t`t`t`t`t`t: " $RASMailboxSettings.SenderAddress
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @("Email address",($Script:htmlsb),$RASMailboxSettings.SenderAddress,$htmlwhite)
     
                    $msg = ""
                    $columnWidths = @("200","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
     
    Function OutputRASReportingSettings
    {
            Param([object] $RASReportingSettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput RAS Reporting configuration"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Reporting"
            }
            If($Text)
            {
                    Line 1 "Reporting"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Reporting"
            }
            
            $SessionInfoRetain = ""
            Switch($RASReportingSettings.TrackSessionTime)
            {
                    0                       {$SessionInfoRetain = "Do not delete"; Break}
                    7257600         {$SessionInfoRetain = "12 weeks"; Break}
                    15724800        {$SessionInfoRetain = "26 weeks"; Break}
                    31449600        {$SessionInfoRetain = "52 weeks"; Break}
                    Default         {$SessionInfoRetain = "Unable to determine Session retain info for: $($RASReportingSettings.TrackSessionTime)"; Break}
            }
            
            $ServerInfoRetain = ""
            Switch($RASReportingSettings.TrackServerTime)
            {
                    0                       {$ServerInfoRetain = "Do not delete"; Break}
                    2419200         {$ServerInfoRetain = "4 weeks"; Break}
                    4838400         {$ServerInfoRetain = "8 weeks"; Break}
                    7257600         {$ServerInfoRetain = "12 weeks"; Break}
                    15724800        {$ServerInfoRetain = "26 weeks"; Break}
                    31449600        {$ServerInfoRetain = "52 weeks"; Break}
                    Default         {$ServerInfoRetain = "Unable to determine Server retain info for: $($RASReportingSettings.TrackServerTime)"; Break}
            }
            
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "RAS Reporting configuration"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Enable RAS Reporting"; Value = $RASReportingSettings.Enabled.ToString(); }) > $Null
                    If($RASReportingSettings.Enabled)
                    {
                            $ScriptInformation.Add(@{Data = '     Server'; Value = $RASReportingSettings.Server; }) > $Null
                            $ScriptInformation.Add(@{Data = '     Port'; Value = $RASReportingSettings.Port.ToString(); }) > $Null
                            If($RASReportingSettings.UseCredentials -eq $False)
                            {
                                    $ScriptInformation.Add(@{Data = '     Prompt user for login details'; Value = ""; }) > $Null
                            }
                            Else
                            {
                                    $ScriptInformation.Add(@{Data = '     Use the following credentials:'; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = '     Username'; Value = $RASReportingSettings.Username; }) > $Null
                            }
     
                            $ScriptInformation.Add(@{Data = 'Session information'; Value = ""; }) > $Null
                            $ScriptInformation.Add(@{Data = "     Enable Tracking"; Value = $RASReportingSettings.TrackSessions.ToString(); }) > $Null
                            If($RASReportingSettings.TrackSessions)
                            {
                                    $ScriptInformation.Add(@{Data = "     Retain information for"; Value = $SessionInfoRetain; }) > $Null
                            }
     
                            $ScriptInformation.Add(@{Data = "Server counters information"; Value = ""; }) > $Null
                            $ScriptInformation.Add(@{Data = "     Enable Tracking"; Value = $RASReportingSettings.TrackServers.ToString() ; }) > $Null
                            If($RASReportingSettings.TrackServers)
                            {
                                    $ScriptInformation.Add(@{Data = "     Retain information for"; Value = $ServerInfoRetain; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Track CPU counter when change is more than"; Value = "$($RASReportingSettings.DeltaCpu) %"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Track Memory counter when change is more than"; Value = "$($RASReportingSettings.DeltaMemory) %"; }) > $Null
                            }
     
                            $ScriptInformation.Add(@{Data = "Custom reports"; Value = ""; }) > $Null
                            $ScriptInformation.Add(@{Data = "     Enable custom reports"; Value = $RASReportingSettings.EnableCustomReports.ToString() ; }) > $Null
                            If($RASReportingSettings.EnableCustomReports)
                            {
                                    $ScriptInformation.Add(@{Data = "     Folder name"; Value = $RASReportingSettings.FolderName; }) > $Null
                            }
                    }
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 250;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 2 "RAS Reporting configuration" 
                    Line 3 "Enable RAS Reporting`t`t`t`t: " $RASReportingSettings.Enabled.ToString()
                    If($RASReportingSettings.Enabled)
                    {
                            Line 3 "Server`t`t`t`t`t`t: " $RASReportingSettings.Server
                            Line 3 "Port`t`t`t`t`t`t: " $RASReportingSettings.Port.ToString()
                            If($RASReportingSettings.UseCredentials -eq $False)
                            {
                                    Line 3 "Prompt user for login details"
                            }
                            Else
                            {
                                    Line 3 "Use the following credentials:"
                                    Line 3 "Username`t`t`t`t`t: " $RASReportingSettings.Username
                            }
     
                            Line 2 "Session information" 
                            Line 3 "Enable Tracking`t`t`t`t`t: " $RASReportingSettings.TrackSessions.ToString()
                            If($RASReportingSettings.TrackSessions)
                            {
                                    Line 3 "Retain information for`t`t`t`t: " $SessionInfoRetain
                            }
     
                            Line 2 "Server counters information" 
                            Line 3 "Enable Tracking`t`t`t`t`t: " $RASReportingSettings.TrackServers.ToString()
                            If($RASReportingSettings.TrackServers)
                            {
                                    Line 3 "Retain information for`t`t`t`t: " $ServerInfoRetain
                                    Line 3 "Track CPU counter when change is more than`t: " "$($RASReportingSettings.DeltaCpu) %"
                                    Line 3 "Track Memory counter when change is more than`t: " "$($RASReportingSettings.DeltaMemory) %"
                            }
     
                            Line 2 "Custom reports"
                            Line 3 "Enable custom reports`t`t`t`t: " $RASReportingSettings.EnableCustomReports.ToString()
                            If($RASReportingSettings.EnableCustomReports)
                            {
                                    Line 3 "Folder name`t`t`t`t`t: " $RASReportingSettings.FolderName
                            }
                    }
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @("RAS Reporting configuration",($Script:htmlsb),"",$htmlwhite)
                    $rowdata += @(,("     Enable RAS Reporting",($Script:htmlsb),$RASReportingSettings.Enabled.ToString(),$htmlwhite))
                    If($RASReportingSettings.Enabled)
                    {
                            $rowdata += @(,("     Server",($Script:htmlsb),$RASReportingSettings.Server,$htmlwhite))
                            $rowdata += @(,("     Port",($Script:htmlsb),$RASReportingSettings.Port.ToString(),$htmlwhite))
                            If($RASReportingSettings.UseCredentials -eq $False)
                            {
                                    $rowdata += @(,("     Prompt user for login details",($Script:htmlsb),"",$htmlwhite))
                            }
                            Else
                            {
                                    $rowdata += @(,("     Use the following credentials:",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("     Username",($Script:htmlsb),$RASReportingSettings.Username,$htmlwhite))
                            }
     
                            $rowdata += @(,("Session information",($Script:htmlsb),"",$htmlwhite))
                            $rowdata += @(,("     Enable Tracking",($Script:htmlsb), $RASReportingSettings.TrackSessions.ToString(),$htmlwhite))
                            If($RASReportingSettings.TrackSessions)
                            {
                                    $rowdata += @(,("     Retain information for",($Script:htmlsb), $SessionInfoRetain,$htmlwhite))
                            }
     
                            $rowdata += @(,("Server counters information",($Script:htmlsb),"",$htmlwhite))
                            $rowdata += @(,("     Enable Tracking",($Script:htmlsb),$RASReportingSettings.TrackServers.ToString(),$htmlwhite))
                            If($RASReportingSettings.TrackServers)
                            {
                                    $rowdata += @(,("     Retain information for",($Script:htmlsb),$ServerInfoRetain,$htmlwhite))
                                    $rowdata += @(,("     Track CPU counter when change is more than",($Script:htmlsb),"$($RASReportingSettings.DeltaCpu) %",$htmlwhite))
                                    $rowdata += @(,("     Track Memory counter when change is more than",($Script:htmlsb),"$($RASReportingSettings.DeltaMemory) %",$htmlwhite))
                            }
     
                            $rowdata += @(,("Custom reports",($Script:htmlsb),"",$htmlwhite))
                            $rowdata += @(,("     Enable custom reports",($Script:htmlsb),$RASReportingSettings.EnableCustomReports.ToString(),$htmlwhite))
                            If($RASReportingSettings.EnableCustomReports)
                            {
                                    $rowdata += @(,("     Folder name",($Script:htmlsb),$RASReportingSettings.FolderName,$htmlwhite))
                            }
                    }
     
                    $msg = ""
                    $columnWidths = @("300","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
     
    Function OutputRASPerformanceMonitorSettings
    {
            Param([object] $RASPerformanceMonitorSettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput RAS Performance Monitor configuration"
            
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "RAS Performance Monitor configuration"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Enable RAS Performance Monitor"; Value = $RASPerformanceMonitorSettings.Enabled.ToString(); }) > $Null
                    If($RASPerformanceMonitorSettings.Enabled)
                    {
                            $ScriptInformation.Add(@{Data = '     Server'; Value = $RASPerformanceMonitorSettings.Server; }) > $Null
                            $ScriptInformation.Add(@{Data = '     Port'; Value = $RASPerformanceMonitorSettings.Port.ToString(); }) > $Null
                    }
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 250;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 2 "RAS Performance Monitor configuration"
                    Line 3 "Enable RAS Performance Monitor`t`t`t: " $RASPerformanceMonitorSettings.Enabled.ToString()
                    If($RASPerformanceMonitorSettings.Enabled)
                    {
                            Line 3 "Server`t`t`t`t`t``t: " $RASPerformanceMonitorSettings.Server
                            Line 3 "Port`t`t`t`t`t``t: " $RASPerformanceMonitorSettings.Port.ToString()
                    }
                    Line 0 ""
            }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @("RAS Performance Monitor configuration",($Script:htmlsb),"",$htmlwhite)
                    $rowdata += @(,("     Enable RAS Performance Monitor",($Script:htmlsb),$RASPerformanceMonitorSettings.Enabled.ToString(),$htmlwhite))
                    If($RASPerformanceMonitorSettings.Enabled)
                    {
                            $rowdata += @(,("     Server",($Script:htmlsb),$RASPerformanceMonitorSettings.Server,$htmlwhite))
                            $rowdata += @(,("     Port",($Script:htmlsb),$RASPerformanceMonitorSettings.Port.ToString(),$htmlwhite))
                    }
     
                    $msg = ""
                    $columnWidths = @("300","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
     
    Function OutputRASNotifications
    {
            Param([object] $RASNotificationHandlers)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Notifications"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "Notifications"
                    WriteWordLine 4 0 "Notification handlers"
            }
            If($Text)
            {
                    Line 1 "Notifications"
                    Line 2 "Notification handlers"
            }
            If($HTML)
            {
                    WriteHTMLLine 3 0 "Notifications"
                    WriteHTMLLine 4 0 "Notification handlers"
            }
            
            ForEach($RASNotificationHandler in $RASNotificationHandlers)
            {
                    If($RASNotificationHandler.HasThreshold)
                    {
                            Switch ($RASNotificationHandler.Direction)
                            {
                                    "LowersBelow"   {$RASNotificationHandlerDirection = "Decreases below"; Break}
                                    "RisesAbove"    {$RASNotificationHandlerDirection = "Rises above"; Break}
                                    Default                 {$RASNotificationHandlerDirection = "Unable to determine notification direction: $($RASNotificationHandler.Direction)"; Break}
                            }
                    }
                    Else
                    {
                            $RASNotificationHandlerDirection = ""
                    }
                    
                    Switch ($RASNotificationHandler.Type)
                    {
                            #listed in the order they appear in the console
                            "CPUEvent"                                              {$RASNotificationText = "CPU utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break}
                            "MemoryEvent"                                   {$RASNotificationText = "Memory utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break}
                            "ConnectedSessionEvent"                 {$RASNotificationText = "Number of RDSH sessions $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}
                            "DisconnectSessionEvent"                {$RASNotificationText = "Number of disconnected RDSH sessions $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}
                            "RDSHConnectSessionEvent"               {$RASNotificationText = "RDSH active sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break}
                            "RDSHDisconnectSessionEvent"    {$RASNotificationText = "RDSH disconnected sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}
                            "34660353"                                              {$RASNotificationText = "AVD active sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break}
                            "34660354"                                              {$RASNotificationText = "AVD disconnected sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}
                            "TunneledSess"                                  {$RASNotificationText = "Number of Secure Gateway tunnelled sessions $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}
                            "GW"                                                    {$RASNotificationText = "Failed Secure Gateway tunnelled sessions"; Break}
                            "1097729"                                               {$RASNotificationText = "Failed Secure Gateway tunnelled sessions"; Break}
                            "Agent"                                                 {$RASNotificationText = "RAS Agents events"; Break}
                            "License"                                               {$RASNotificationText = "Licensing events"; Break}
                            "Authentication"                                {$RASNotificationText = "Authentication server events"; Break}
                            "PubItem"                                               {$RASNotificationText = "Published items events"; Break}
                            "VDI"                                                   {$RASNotificationText = "Template events"; Break}
                            "45056"                                                 {$RASNotificationText = "Tenants events"; Break}
                            "Unknown"                                               {$RASNotificationText = "Unknown"; Break}
                            Default                                                 {$RASNotificationText = "Unable to determine event type: $($RASNotificationHandler.Type)"; Break}
                    }
                    
                    $GracePeriod           = ($RASNotificationHandler.GracePeriod.ToString())
                    $NotificationsInterval = ($RASNotificationHandler.Interval.ToString())
                    
                    If($MSWord -or $PDF)
                    {
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Events"; Value = $RASNotificationText; }) > $Null
                            $ScriptInformation.Add(@{Data = 'Enabled'; Value = $RASNotificationHandler.Enabled.ToString(); }) > $Null
                            If($RASNotificationHandler.Enabled)
                            {
                                    $ScriptInformation.Add(@{Data = 'Send email to RAS administrators'; Value = $RASNotificationHandler.SendEmail; }) > $Null
                                    
                                    If($RASNotificationHandler.Recipients -eq "")
                                    {
                                            $ScriptInformation.Add(@{Data = 'Handler'; Value = ""; }) > $Null
                                    }
                                    Else
                                    {
                                            $tmpArray = $RASNotificationHandler.Recipients.Split(",").Split(";")
                                            
                                            $cnt = -1
                                            ForEach($item in $tmpArray)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = 'Handler'; Value = $item; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = ''; Value = $item; }) > $Null
                                                    }
                                            }
                                            $tmpArray = $Null
                                    }
                                    $ScriptInformation.Add(@{Data = 'Execute a notification script'; Value = $RASNotificationHandler.ExecuteScript; }) > $Null
                                    
                                    If($RASNotificationHandler.ExecuteScript)
                                    {
                                            $results = Get-RASNotificationScript -id $RASNotificationHandler.ScriptId -EA 0 4>$Null
                                            
                                            If(!($?))
                                            {
                                                    $ScriptName = "Unable to retrieve script name"
                                            }
                                            Else
                                            {
                                                    $ScriptName = $results.Name
                                            }
                                            
                                            $ScriptInformation.Add(@{Data = ''; Value = $ScriptName; }) > $Null
                                            $ScriptName = $Null
                                    }
     
                                    $ScriptInformation.Add(@{Data = 'Notification handler grace period'; Value = "$GracePeriod minutes"; }) > $Null
                                    If($RASNotificationHandler.EnableInterval)
                                    {
                                            $ScriptInformation.Add(@{Data = 'Notifications interval'; Value = "$NotificationsInterval minutes"; }) > $Null
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = 'Send one notification and suspend further notifications until recovered'; Value = ""; }) > $Null
                                    }
                            }
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 250;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                    }
                    If($Text)
                    {
                            Line 3 "Events`t`t`t`t`t: " $RASNotificationText
                            Line 3 "Enabled`t`t`t`t`t: " $RASNotificationHandler.Enabled.ToString()
                            If($RASNotificationHandler.Enabled)
                            {
                                    Line 3 "Send email to RAS administrators`t: " $RASNotificationHandler.SendEmail
                                    
                                    If($RASNotificationHandler.Recipients -eq "")
                                    {
                                            Line 3 "Handler`t`t`t`t`t: " ""
                                    }
                                    Else
                                    {
                                            $tmpArray = $RASNotificationHandler.Recipients.Split(",").Split(";")
                                            
                                            $cnt = -1
                                            ForEach($item in $tmpArray)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            Line 3 "Handler`t`t`t`t`t: " $item
                                                    }
                                                    Else
                                                    {
                                                            Line 8 '  ' $item
                                                    }
                                            }
                                            $tmpArray = $Null
                                    }
                                    Line 3 "Execute a notification script`t`t: " $RASNotificationHandler.ExecuteScript
                                    
                                    If($RASNotificationHandler.ExecuteScript)
                                    {
                                            $results = Get-RASNotificationScript -id $RASNotificationHandler.ScriptId -EA 0 4>$Null
                                            
                                            If(!($?))
                                            {
                                                    $ScriptName = "Unable to retrieve script name"
                                            }
                                            Else
                                            {
                                                    $ScriptName = $results.Name
                                            }
                                            
                                            Line 8 '  ' $ScriptName
                                            $ScriptName = $Null
                                    }
     
                                    Line 3 "Notification handler grace period`t: " "$GracePeriod minutes"
                                    If($RASNotificationHandler.EnableInterval)
                                    {
                                            Line 3 "Notifications interval`t`t`t: " "$NotificationsInterval minutes"
                                    }
                                    Else
                                    {
                                            Line 3 'Send one notification and suspend further notifications until recovered'
                                    }
                            }
                            Line 0 ""
                    }
                    If($HTML)
                    {
                            $rowdata = @()
                            $columnHeaders = @("Events",($Script:htmlsb),$RASNotificationText,$htmlwhite)
                            $rowdata += @(,("Enabled",($Script:htmlsb),$RASNotificationHandler.Enabled.ToString(),$htmlwhite))
                            If($RASNotificationHandler.Enabled)
                            {
                                    $rowdata += @(,("Send email to RAS administrators",($Script:htmlsb),$RASNotificationHandler.SendEmail.ToString(),$htmlwhite))
                                    
                                    If($RASNotificationHandler.Recipients -eq "")
                                    {
                                            $rowdata += @(,("Handler",($Script:htmlsb),"",$htmlwhite))
                                    }
                                    Else
                                    {
                                            $tmpArray = $RASNotificationHandler.Recipients.Split(",").Split(";")
                                            
                                            $cnt = -1
                                            ForEach($item in $tmpArray)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $rowdata += @(,("Handler",($Script:htmlsb),$item,$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))
                                                    }
                                            }
                                            $tmpArray = $Null
                                    }
                                    $rowdata += @(,("Execute a notification script",($Script:htmlsb),$RASNotificationHandler.ExecuteScript.ToString(),$htmlwhite))
                                    
                                    If($RASNotificationHandler.ExecuteScript)
                                    {
                                            $results = Get-RASNotificationScript -id $RASNotificationHandler.ScriptId -EA 0 4>$Null
                                            
                                            If(!($?))
                                            {
                                                    $ScriptName = "Unable to retrieve script name"
                                            }
                                            Else
                                            {
                                                    $ScriptName = $results.Name
                                            }
                                            
                                            $rowdata += @(,("",($Script:htmlsb),$ScriptName,$htmlwhite))
                                            $ScriptName = $Null
                                    }
     
                                    $rowdata += @(,( "Notification handler grace period",($Script:htmlsb),"$GracePeriod minutes",$htmlwhite))
                                    If($RASNotificationHandler.EnableInterval)
                                    {
                                            $rowdata += @(,("Notifications interval",($Script:htmlsb),"$NotificationsInterval minutes",$htmlwhite))
                                    }
                                    Else
                                    {
                                            $rowdata += @(,("Send one notification and suspend further notifications until recovered",($Script:htmlsb),"",$htmlwhite))
                                    }
                            }
     
                            $msg = ""
                            $columnWidths = @("250","225")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                    }
            }
    }
     
    Function OutputRASNotificationScripts
    {
            Param([object] $RASNotificationScripts)
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 4 0 "Notification scripts"
            }
            If($Text)
            {
                    Line 2 "Notification scripts"
            }
            If($HTML)
            {
                    WriteHTMLLine 4 0 "Notification scripts"
            }
            
            ForEach($RASNotificationScript in $RASNotificationScripts)
            {
                    If($MSWord -or $PDF)
                    {
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Script name"; Value = $RASNotificationScript.Name; }) > $Null
                            $ScriptInformation.Add(@{Data = 'Command'; Value = $RASNotificationScript.Command; }) > $Null
                            $ScriptInformation.Add(@{Data = 'Arguments'; Value = $RASNotificationScript.Arguments; }) > $Null
                            $ScriptInformation.Add(@{Data = 'Initial directory'; Value = $RASNotificationScript.InitialDirectory; }) > $Null
                            $ScriptInformation.Add(@{Data = 'User name'; Value = $RASNotificationScript.Username; }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 250;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                    }
                    If($Text)
                    {
                            Line 3 "Script name`t`t`t: " $RASNotificationScript.Name
                            Line 3 "Command`t`t`t`t: " $RASNotificationScript.Command
                            Line 3 "Arguments`t`t`t: " $RASNotificationScript.Arguments
                            Line 3 "Initial directory`t`t: " $RASNotificationScript.InitialDirectory
                            Line 3 "User name`t`t`t: " $RASNotificationScript.Username
                            Line 0 ""
                    }
                    If($HTML)
                    {
                            $rowdata = @()
                            $columnHeaders = @("Script name",($Script:htmlsb),$RASNotificationScript.Name,$htmlwhite)
                            $rowdata += @(,("Command",($Script:htmlsb),$RASNotificationScript.Command,$htmlwhite))
                            $rowdata += @(,("Arguments",($Script:htmlsb),$RASNotificationScript.Arguments,$htmlwhite))
                            $rowdata += @(,("Initial directory",($Script:htmlsb),$RASNotificationScript.InitialDirectory,$htmlwhite))
                            $rowdata += @(,("User name",($Script:htmlsb),$RASNotificationScript.Username,$htmlwhite))
     
                            $msg = ""
                            $columnWidths = @("200","225")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                    }
            }
    }
     
    Function OutputRASClientSettings
    {
            Param([object] $RASClientSettings)
     
            <#
            ExcludeDirectRDP         :
            ExcludeDirectRDPForVDI   :
            SendHDIcons              : True
            ReplicateSendHDIcons     : True
            EnableOverlayIcons       : True
            ShowPasswordExpiry       : False
            TokenValidationExpireMin : 60
            #>
     
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "Client settings"
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Published application icons"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Resolution:"; Value = ""; }) > $Null
                    If($RASClientSettings.SendHDIcons)
                    {
                            $ScriptInformation.Add(@{Data = "          High resolution icons (uses more network bandwidth)"; Value = ""; }) > $Null
                    }
                    Else
                    {
                            $ScriptInformation.Add(@{Data = "          Standard resolution icons"; Value = ""; }) > $Null
                    }
                    $ScriptInformation.Add(@{Data = "     Overlay:"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "          $($RASClientSettings.EnableOverlayIcons.ToString())"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "Password notifications"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Show password expiration reminder"; Value = $RASClientSettings.ShowPasswordExpiry.ToString(); }) > $Null
                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASClientSettings.ReplicateSendHDIcons.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 200;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
     
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 2 "Client settings"
                    Line 3 "Published application icons"
                    Line 4 "Resolution:"
                    If($RASClientSettings.SendHDIcons)
                    {
                            Line 5 "High resolution (uses more network bandwidth)"
                    }
                    Else
                    {
                            Line 5 "Standard resolution"
                    }
                    Line 4 "Overlay:"
                    Line 5 "Enable overlay icon`t : " $RASClientSettings.EnableOverlayIcons.ToString()
                    LIne 3 "Password notifications"
                    Line 4 "Show password expiration reminder: " $RASClientSettings.ShowPasswordExpiry.ToString()
                    Line 3 "Settings are replicated to all Sites`t : " $RASClientSettings.ReplicateSendHDIcons.ToString()
                    Line 0 ""
            }
            If($HTML)
            {
                    WriteHTMLLine 3 0 "Client settings"
                    $rowdata = @()
                    $columnHeaders = @("Published application icons",($Script:htmlsb),"S",$htmlwhite)
                    $rowdata += @(,("     Resolution:",($Script:htmlsb),"",$htmlwhite))
                    If($RASClientSettings.SendHDIcons)
                    {
                            $rowdata += @(,("          High resolution (uses more network bandwidth)",($Script:htmlsb),"",$htmlwhite))
                    }
                    Else
                    {
                            $rowdata += @(,("          Standard resolution",($Script:htmlsb),"",$htmlwhite))
                    }
                    $rowdata += @(,("     Overlay:",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("          $($RASClientSettings.EnableOverlayIcons.ToString())",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("Password notifications",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("     Show password expiration reminder",($Script:htmlsb),$RASClientSettings.ShowPasswordExpiry.ToString(),$htmlwhite))
                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASClientSettings.ReplicateSendHDIcons.ToString(),$htmlwhite))
     
                    $msg = ""
                    $columnWidths = @("200","275")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
     
                    WriteHTMLLine 0 0 ""
            }
     
    }
    #endregion
     
    #region process licensing
    Function ProcessLicensing
    {
            Write-Verbose "$(Get-Date -Format G): Processing Licensing"
     
            $results = Get-RASLicenseDetails -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve licensing information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve licensing information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve licensing information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve licensing information"
                    }
            }
            ElseIf($? -and $null -eq $results)
            {
                    Write-Warning "No licensing information was found"
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No licensing information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No licensing information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No licensing information was found"
                    }
            }
            Else
            {
                    OutputRASLicense $results
            }
    }
     
    Function OutputRASLicense
    {
            Param([object] $RASLicense)
            
            Write-Verbose "$(Get-Date -Format G): `tOutput RAS License"
     
            If($MSWord -or $PDF)
            {
                    $Script:Selection.InsertNewPage()
                    WriteWordLine 1 0 "License details"
                    $ScriptInformation = New-Object System.Collections.ArrayList
            }
            If($Text)
            {
                    Line 0 "License details"
            }
            If($HTML)
            {
                    WriteHTMLLine 1 0 "License details"
                    $rowdata = @()
            }
     
            If($MSWord -or $PDF)
            {
                    $ScriptInformation.Add(@{Data = "License Type"; Value = $RASLicense.LicenseType; }) > $Null
                    If(ValidObject $RASLicense LicenseKey)
                    {
                            $ScriptInformation.Add(@{Data = "License Key"; Value = $RASLicense.LicenseKey; }) > $Null
                    }
                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                    If(ValidObject $RASLicense SupportExpireDate)
                    {
                            $ScriptInformation.Add(@{Data = "Support Expiration Date"; Value = $RASLicense.SupportExpireDate; }) > $Null
                    }
                    If(ValidObject $RASLicense ExpiryDate)
                    {
                            $ScriptInformation.Add(@{Data = "Expiration Date"; Value = $RASLicense.ExpiryDate; }) > $Null
                    }
                    If(ValidObject $RASLicense LicenseFirstActive)
                    {
                            $ScriptInformation.Add(@{Data = "First Activation"; Value = $RASLicense.LicenseFirstActive; }) > $Null
                    }
                    $ScriptInformation.Add(@{Data = 'Maximum allowed concurrent users'; Value = $RASLicense.InstalledUsers; }) > $Null
                    $ScriptInformation.Add(@{Data = 'Peak Users'; Value = $RASLicense.UsersPeak; }) > $Null
                    $ScriptInformation.Add(@{Data = 'Concurrent Users'; Value = $RASLicense.UsersLicenseInfo; }) > $Null
                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                    If(ValidObject $RASLicense PAUserEmail)
                    {
                            $ScriptInformation.Add(@{Data = 'Parallels Account user email'; Value = $RASLicense.PAUserEmail; }) > $Null
                    }
                    If(ValidObject $RASLicense PAUserName)
                    {
                            $ScriptInformation.Add(@{Data = 'Parallels Account user name'; Value = $RASLicense.PAUserName; }) > $Null
                    }
                    If(ValidObject $RASLicense PACompanyName)
                    {
                            $ScriptInformation.Add(@{Data = 'Parallels Account company'; Value = $RASLicense.PACompanyName; }) > $Null
                    }
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 250;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 1 "License Type`t`t`t: " $RASLicense.LicenseType
                    If(ValidObject $RASLicense LicenseKey)
                    {
                            Line 1 "License Key`t`t`t: " $RASLicense.LicenseKey
                    }
                    Line 0 ""
                    If(ValidObject $RASLicense SupportExpireDate)
                    {
                            Line 1 "Support Expiration Date`t`t: " $RASLicense.SupportExpireDate
                    }
                    If(ValidObject $RASLicense ExpiryDate)
                    {
                            Line 1 "Expiration Date`t`t`t: " $RASLicense.ExpiryDate
                    }
                    If(ValidObject $RASLicense LicenseFirstActive)
                    {
                            Line 1 "First Activation`t`t: " $RASLicense.LicenseFirstActive
                    }
                    Line 1 "Maximum allowed concurrent users: " $RASLicense.InstalledUsers
                    Line 1 "Peak Users`t`t`t: " $RASLicense.UsersPeak
                    Line 1 "Concurrent Users`t`t: " $RASLicense.UsersLicenseInfo
                    Line 0 ""
                    If(ValidObject $RASLicense PAUserEmail)
                    {
                            Line 1 "Parallels Account user email`t: " $RASLicense.PAUserEmail
                    }
                    If(ValidObject $RASLicense PAUserName)
                    {
                            Line 1 "Parallels Account user name`t: " $RASLicense.PAUserName
                    }
                    If(ValidObject $RASLicense PACompanyName)
                    {
                            Line 1 "Parallels Account company`t: " $RASLicense.PACompanyName
                    }
                    Line 0 ""
            }
            If($HTML)
            {
                    $columnHeaders = @("License Type",($Script:htmlsb),$RASLicense.LicenseType,$htmlwhite)
                    If(ValidObject $RASLicense LicenseKey)
                    {
                            $rowdata += @(,("License Key",($Script:htmlsb),$RASLicense.LicenseKey,$htmlwhite))
                    }
                    $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                    If(ValidObject $RASLicense SupportExpireDate)
                    {
                            $rowdata += @(,("Support Expiration Date",($Script:htmlsb),$RASLicense.SupportExpireDate,$htmlwhite))
                    }
                    $rowdata += @(,("Expiration Date",($Script:htmlsb),$RASLicense.ExpiryDate,$htmlwhite))
                    If(ValidObject $RASLicense ExpiryDate)
                    {
                            $rowdata += @(,("Expiration Date",($Script:htmlsb),$RASLicense.ExpiryDate,$htmlwhite))
                    }
                    If(ValidObject $RASLicense LicenseFirstActive)
                    {
                            $rowdata += @(,("First Activation",($Script:htmlsb),$RASLicense.LicenseFirstActive,$htmlwhite))
                    }
                    $rowdata += @(,("Maximum allowed concurrent users",($Script:htmlsb),$RASLicense.InstalledUsers,$htmlwhite))
                    $rowdata += @(,("Peak Users",($Script:htmlsb),$RASLicense.UsersPeak,$htmlwhite))
                    $rowdata += @(,("Concurrent Users",($Script:htmlsb),$RASLicense.UsersLicenseInfo,$htmlwhite))
                    $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                    If(ValidObject $RASLicense PAUserEmail)
                    {
                            $rowdata += @(,("Parallels Account user email",($Script:htmlsb),$RASLicense.PAUserEmail,$htmlwhite))
                    }
                    If(ValidObject $RASLicense PAUserName)
                    {
                            $rowdata += @(,("Parallels Account user name",($Script:htmlsb),$RASLicense.PAUserName,$htmlwhite))
                    }
                    If(ValidObject $RASLicense PACompanyName)
                    {
                            $rowdata += @(,("Parallels Account company",($Script:htmlsb),$RASLicense.PACompanyName,$htmlwhite))
                    }
     
                    $msg = ""
                    $columnWidths = @("200","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
    #endregion
     
    #region script core
    #Script begins
     
    ProcessScriptSetup
     
    ProcessFarm
     
    SetFilenames "Parallels_RAS_$Script:RASFarmName"
     
    OutputFarm
     
    GetFarmSites
     
    $OnlyOneTIme = $True
    ForEach($Site in $Script:Sites)
    {
            If($OnlyOneTIme)
            {
                    OutputFarmSite $Site
                    
                    $OnlyOneTime = $False
            }
     
            OutputSite $Site
     
            ProcessLoadBalancing $Site
     
            ProcessPublishing $Site
     
            ProcessUniversalPrinting $Site
     
            ProcessUniversalScanning $Site
     
            ProcessConnection $Site
    }
     
    ProcessPolicies
     
    ProcessAdministration
     
    ProcessLicensing
     
    #endregion
     
    #region finish script
    Write-Verbose "$(Get-Date -Format G): Finishing up document"
    #end of document processing
     
    If(($MSWORD -or $PDF) -and ($Script:CoverPagesExist))
    {
            $AbstractTitle = "Parallels RAS Inventory Report"
            $SubjectTitle = "Parallels RAS Inventory Report"
            UpdateDocumentProperties $AbstractTitle $SubjectTitle
    }
     
    If($ReportFooter)
    {
            OutputReportFooter
    }
     
    ProcessDocumentOutput "Regular"
     
    ProcessScriptEnd
    #endregion